2008/6/2 J. Shirley &lt;<a href="mailto:jshirley@gmail.com">jshirley@gmail.com</a>&gt;:<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 &lt;<a href="mailto:cuiyuming@gmail.com">cuiyuming@gmail.com</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt; Hi,<br>
&gt;<br>
&gt; When a page loaded in firefox, &nbsp;then it will send a ajax request to get data<br>
&gt; in json format.<br>
&gt;<br>
&gt; Some gb2312 words is in the json data.<br>
&gt;<br>
&gt; When catalyst is started by /home/robin/CBS/script/cbs_server.pl, the data<br>
&gt; got by client is same as the data i print on the screen by $c-&gt;log-&gt;debug().<br>
&gt; It&#39;s showed corrected in firefox client or ie client.<br>
&gt;<br>
&gt; But when catalyst is running by apache mod_perl, the data got by client is<br>
&gt; different from the data i print on the screen by $c-&gt;log-&gt;debug().It&#39;s<br>
&gt; showed incorrected.<br>
&gt;<br>
&gt; A chinese world in gb2312 charset have 2 bytes. &nbsp;what I found in the client<br>
&gt; is that:<br>
&gt;<br>
&gt; 2 bytes of a chinese word was splited, and a octal byte \303 or \302 was<br>
&gt; added before every byte. So showed incorrect in client.<br>
&gt;<br>
&gt; Anyone meet the same problem when using mod_perl?<br>
&gt;<br>
&gt; Thanks!<br>
&gt;<br>
&gt; Robincui<br>
&gt;<br>
&gt;<br>
<br>
</div></div>How are you generating the JSON? &nbsp;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. &nbsp;I<br>
try to use Catalyst::View::JSON wherever possibly, and if it isn&#39;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>&nbsp;&nbsp;&nbsp; my $json = new JSON;<br>&nbsp;&nbsp;&nbsp; $json-&gt;canonical(1);<br>&nbsp;&nbsp;&nbsp; my $response = $json-&gt;encode($var);<br><br>But i think the problem is nothing to do with JSON,&nbsp; for some points like below:<br>
1. The problem will not occur when I use catalyst&#39;s built-in server<br>2. After JSON module convert a hash to JSON data, I use $c-&gt;log-&gt;debug&nbsp; 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&#39;t kown why?<br>
Some code like below:<br><br>&nbsp;&nbsp;&nbsp; my $jsResponse = $ajaxRequest-&gt;{response} . &quot;\n$callback_function&quot;;<br>&nbsp;&nbsp;&nbsp; $c-&gt;log-&gt;debug(&quot;JS Response:\n$jsResponse&quot;); # the showed on the screen is correct;<br>
&nbsp;&nbsp;&nbsp; $c-&gt;response-&gt;content_type(&#39;text/html; charset=GB2312&#39;);<br>&nbsp;&nbsp;&nbsp; $c-&gt;response-&gt;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>&nbsp;</div></div><br>
Any other solution?