2008/6/2 J. Shirley <<a href="mailto:jshirley@gmail.com">jshirley@gmail.com</a>>:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2008/6/1 cui robin <<a href="mailto:cuiyuming@gmail.com">cuiyuming@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Hi,<br>
><br>
> When a page loaded in firefox, then it will send a ajax request to get data<br>
> in json format.<br>
><br>
> Some gb2312 words is in the json data.<br>
><br>
> When catalyst is started by /home/robin/CBS/script/cbs_server.pl, the data<br>
> got by client is same as the data i print on the screen by $c->log->debug().<br>
> It's showed corrected in firefox client or ie client.<br>
><br>
> But when catalyst is running by apache mod_perl, the data got by client is<br>
> different from the data i print on the screen by $c->log->debug().It's<br>
> showed incorrected.<br>
><br>
> A chinese world in gb2312 charset have 2 bytes. what I found in the client<br>
> is that:<br>
><br>
> 2 bytes of a chinese word was splited, and a octal byte \303 or \302 was<br>
> added before every byte. So showed incorrect in client.<br>
><br>
> Anyone meet the same problem when using mod_perl?<br>
><br>
> Thanks!<br>
><br>
> Robincui<br>
><br>
><br>
<br>
</div></div>How are you generating the JSON? We had a similar circumstance<br>
(although our production server would also exhibit failures under the<br>
built-in server) because of varying JSON.pm versions.<br>
<br>
Make sure you use a JSON module that properly understands unicode. I<br>
try to use Catalyst::View::JSON wherever possibly, and if it isn't<br>
then JSON::XS::encode_json( $perlref ) works the most reliably.<br>
<br>
-J</blockquote><div>I use standard JSON module [use JSON;] from cpan,version is 2.07. code like below:<br> my $json = new JSON;<br> $json->canonical(1);<br> my $response = $json->encode($var);<br><br>But i think the problem is nothing to do with JSON, for some points like below:<br>
1. The problem will not occur when I use catalyst's built-in server<br>2. After JSON module convert a hash to JSON data, I use $c->log->debug output to screen, I saw it was correct.<br><br>I think the problem occur when apache (mod_perl) send data to client. the data was modified. But I don't kown why?<br>
Some code like below:<br><br> my $jsResponse = $ajaxRequest->{response} . "\n$callback_function";<br> $c->log->debug("JS Response:\n$jsResponse"); # the showed on the screen is correct;<br>
$c->response->content_type('text/html; charset=GB2312');<br> $c->response->body($jsResponse);<br><br>The mod_perl,apache,perl version like below:<br>[Mon Jun 02 12:28:31 2008] [notice] Apache/2.0.55 (Unix) PHP/5.2.3 mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations<br>
</div><div> </div></div><br>
Any other solution?