I think you can solve this simply by executing a "SET NAMES 'utf8'" SQL
Request at the start of every script (in your bootstrap or initializer
plugin for example).
It's common to all PHP apps using MySQL with UTF8, and It's always
really... displeasant to spend hours searching the reason.
Hope this helps,
Lucas
//
joostvanveen a écrit :
Hi all,
This is really tearing me apart. Any help would be greatly appreciated.
I take data from my database and echo it in XML. But something goes wrong
with encoding along the way.
- Database is mysql 5, collation utf-8, character set for connection is
utf-8.
- Zend_Db_Adapter is PdoMysql
This is some content that I have stored in my database:
test: €, µ, Ò, Ð, ¶, č, ņ, ų, ß
It should be stored OK, because in PhpMyadmin it displays nicely as it
should.
However, when I print it to screen, I see:
test: �, �, �, �, �, ?, ?, ?, �
When I wrap the string in ut8_encode it improves a little, but still not OK:
test: , µ, Ò, Ð, ¶, ?, ?, ?, ß
I print to screen directly from controller. This is my code:
$this->_helper->viewRenderer->setNoRender(true);
header('Content-type: text/xml; charset=utf-8');
echo $xmlString;
Response headers says Content-Type: text/xml; charset=utf-8, like it should.
So it seems that the problem lies somewhere between data collection from
database and printing on screen. But I'm at my wit's end here...