marc et al - <br>question is more in the world of common::sense and utf8, but i'm seeing this in AE, so am seeking clarification/hints here on this list.<br><br>Does Perl tag a whole data structure non-utf8 if part of it is not?<br>
What happens in complex data structures with some part that is not utf8? <br>
<br>tl;dr - 2 fetches of JSON; one has entities escaped in the output JSON as \uNNN and the other ends up getting messed up.<br>here's the relevant pseudo code:<br>---start----<br>my %data;<br># Anyevent::HTTP<br>http_get <a href="http://foo.com/">http://foo.com/</a>, sub { <br>
$data{bar} = JSON::XS->new->decode( $_[0] );<br>}<br>http_get <a href="http://bar.com">http://bar.com</a>, sub {<br> $data{bar} = JSON::XS->new->decode( $_[0] );<br>}<br># later<br clear="all">print JSON::XS->new->encode( \%data ); # broken!<br>
<br>---end-pseudo--<br><br>What i'm seeing is <a href="http://foo.com">foo.com</a> has JSON with \uNNN inside of it, and <a href="http://bar.com">bar.com</a> has a bad case of mojibake when shared in %data<br>Curiously though, i print the raw body --or the JSON::XS parse inside the <a href="http://bar.com">bar.com</a> CB, and guess what? it's fine!<br>
<br>But after i put the data in to the container %data, <a href="http://bar.com">bar.com</a> json object gets scrambled chars. <br><br>If i got the source input correct in both, then this problem seems to disappear.<br><br>
WTF?!?<br><br>thanks in advance!<br><br>-gleeco<br>