Hi,
Try to put this code in your bootstrap file, that encode your dialog with
the database:
$db = Zend_Registry::get('db');
$db->query("SET NAMES $charset"); ($charset is UTF-8, obtained from config).
joostvanveen wrote:
>
> 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.
>
> When I hardcode the text in my Controller, it displays just fine.
> $this->_helper->viewRenderer->setNoRender(true);
> header('Content-type: text/xml; charset=utf-8');
> echo '€, µ, Ò, Ð, ¶, č, ņ, ų, ß';
>
> So it seems that the problem lies somewhere between data collection from
> database and printing on screen. Did I not set a proper settng for the
> database adapter? Is there an encoding problem in
> Zend_Db_Adapter_Pdo_Mysql regarding character encoding? I'm at my wit's
> end here...
>
--
View this message in context:
http://www.nabble.com/UTF-8-from-database-tp22597212p22597563.html
Sent from the Zend Framework mailing list archive at Nabble.com.