[Catalyst] Strange Problem: gb2312 showed incorrect in mod_perl, but correct in developer server

J. Shirley jshirley at gmail.com
Sun Jun 1 18:25:47 BST 2008

2008/6/1 cui robin <cuiyuming at gmail.com>:
> Hi,
> When a page loaded in firefox,  then it will send a ajax request to get data
> in json format.
> Some gb2312 words is in the json data.
> When catalyst is started by /home/robin/CBS/script/cbs_server.pl, the data
> got by client is same as the data i print on the screen by $c->log->debug().
> It's showed corrected in firefox client or ie client.
> But when catalyst is running by apache mod_perl, the data got by client is
> different from the data i print on the screen by $c->log->debug().It's
> showed incorrected.
> A chinese world in gb2312 charset have 2 bytes.  what I found in the client
> is that:
> 2 bytes of a chinese word was splited, and a octal byte \303 or \302 was
> added before every byte. So showed incorrect in client.
> Anyone meet the same problem when using mod_perl?
> Thanks!
> Robincui

How are you generating the JSON?  We had a similar circumstance
(although our production server would also exhibit failures under the
built-in server) because of varying JSON.pm versions.

Make sure you use a JSON module that properly understands unicode.  I
try to use Catalyst::View::JSON wherever possibly, and if it isn't
then JSON::XS::encode_json( $perlref ) works the most reliably.


More information about the Catalyst mailing list