Open up your source view for the bad output and check what it contains.

If you want to display UTF-8, you need to maintain a UTF-8 encoding at all 
times. I'm also not sure about all the mb_* contortions you're going through. 
Why are you converting from UTF-8 to the IANA HTML-ENTITIES? Use Zend_View's 
escape() method which will run it through htmlspecialchars() and leave any 
multibyte characters intact.

I would also avoid using header() directly - there's a response object floating 
around your controller layer which can be used to handle headers. You can 
access it from within a base controller or from the front controller. This is 
one likely suspect. See:
http://framework.zend.com/manual/en/zend.controller.response.html#zend.controller.response.headers

Do you have tools like Live Headers (Firefox extension) to view the actual 
headers being sent to your browser? The question marks are a sure sign that the 
header encoding and output encoding are not matching causing the browser to 
substitute ? for characters it sees as being malformed.

Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.patternsforphp.com
OpenID Europe Foundation Member-Subscriber


----- Original Message ----
From: Roberto Bouza <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, October 5, 2007 5:41:24 AM
Subject: [fw-general] UTF-8 and Views... weird chars

Hello Everyone.

I've been battling with this for a while. Now I need some help to try to figure 
this out.

I just want to show on a view accented characters or something like:

$str = "La Caña de Azúcar"


If I use PHP by itself it works fine. Ex:

$str2 = mb_convert_encoding($str, 'HTML-ENTITIES', 'UTF-8');
echo $str2
echo $str

That code on PHP returns "La Caña de Azúcar" (twice) now if do that piece of 
code on Zend Framework on the controller like:


$this->view->title = $str;
$this->view->encoding = "Encoding: " . mb_detect_encoding($str);
$this->view->converted = mb_convert_encoding($str, 'HTML-ENTITIES', 
mb_detect_encoding($str));


I get:

La Ca?a de Az?car
Encoding: UTF-8
La Caa de Azcar

I've set up on the view:

$this->setEncoding('UTF-8');

I have set up the header:

header('Content-Type: text/html; charset=utf-8');


No luck. Any help would be greatly appreciated.

Thank you.












       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

Reply via email to