[Catalyst] Double encoding of UTF8 strings

jul.gil at gmail.com jul.gil at gmail.com
Fri Oct 7 09:21:08 GMT 2011


Hi,

I have installed and ran successfully the AutoCRUD plugin, I set up a
mysql database tables to use UT8 charset, the charset in the ajax
requests is utf-8, everything seems correct, except the data in the
grids are double encoded, that means é instead of é.

I am pretty sure that the data in the database are correct, and the
json data are also correctly displayed (the raw data received contains
the wrong characters). The double encoding seems then to appear in the
View of AutoCRUD, that is just a Catalyst::JSON::View simply used
without any customization.

I have hacked around this AutoCRUD JSON view, and end up with a solution :
- overload the encode_json method in the view to call directly
JSON::XS without the utf8 call, ie a simple
JSON::XS->new->encode($data);
- and overload the process method in order to remove the  $json =
Encode::encode($encoding, $json);

In short : don't touch my data, they are already in utf8, just send
them to the browser. It works, but I don't know why...

It is probably a bad solution, as I can't imagine that
Catalyst::JSON::View is wrong, but I wonder what is the correct way to
do it.
Couldn't it be a problem in DBIx::Class that does not correctly handle
ut8 columns ?

--
Julien Gilles.



More information about the Catalyst mailing list