Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: JSON::XS and unicode

by philiprbrenan (Monk)
on Sep 08, 2012 at 20:02 UTC ( #992523=note: print w/ replies, xml ) Need Help??


in reply to JSON::XS and unicode

You are trying to write a unicode encoded character to a file but the file has not been opened with an encoding that can cope. You need something like this (untested):

{open(my $F, ">:encoding(UTF-8)", $f) or die "Cannot open $f"; say {$F} $s; }


Comment on Re: JSON::XS and unicode
Download Code
Re^2: JSON::XS and unicode
by kimmel (Beadle) on Sep 08, 2012 at 20:11 UTC

    I am using utf8::all which already takes care of turning on the different unicode parts.

    The errors do not come from reading or writing a file. The error is caused by using decode_json() on a string which should work.

      Thanks for the pointer to utf8::all, it'll be handy.

          -- Chip Salzenberg, Free-Floating Agent of Chaos

      Could you replace the characters in the input to JSON with a's one by one until the offending wide character disappears? We will then know exactly which input character is causing the problem. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992523]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-08-20 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (107 votes), past polls