Character Encoding and Zend_Form

Here’s a poser for you. Open up a controller and its view and try this:


$this->view->utf8 = 'Si Señor!';
 $this->view->html = 'Le Crépe';
$btn1 = new Zend_Form_Element_Button('btn1');
$btn2 = new Zend_Form_Element_Button('btn2');
$this->view->btn1 = $btn1;
 $this->view->btn2 = $btn2;


<?php echo 'utf-8: '.$this->utf8.'<br />'
 'html: '.$this->html.'<br />'
 'btn1: '.$this->btn1.'<br />'
 'btn2: '.$this->btn2; ?>


utf8: Si Se�or!
html: Le Crépe
btn1: ()
btn2: (Le Cr&eacute;pe)

the (buttons) render, but:
the first one is blank (kind of expected as the utf8 variable doesn’t display either)
the 2nd one displays a label, and the html variable worked as we knew it would, however the &acute; entity is displaying in the label.

what does this mean?
does it mean that! the Zend_Form_Element_Button has doubly encoded it?
it must have sent Cr&amp;eacute;pe to the browser!

This is busting my chops! Send it unencoded and it fails to render the label, and send it encoded and it gets encoded twice 😐

Screen Shot 2013-02-06 at 22.02.22

UPDATE: You’ve checked character encoding in your code, mac textedit, the db, the templates, the form decorators,  the form filters, the forums, irc, but guess what? you forgot the IDE.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s