Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: UTF8 with YAML or JSON

by Your Mother (Canon)
on Jul 02, 2012 at 13:47 UTC ( #979436=note: print w/ replies, xml ) Need Help??


in reply to UTF8 with YAML or JSON

I'm mostly just repeating clues already given–

my @in  = <DATA>;
my $in  = join("",@in);
my $dat = Load($in);

print $dat->{x}, $/;
print length($dat->{x}), $/;

__DATA__
x: ă
moo@cow~>perl -MYAML::Syck pm-979143
ă
2
moo@cow~>perl -MYAML::XS pm-979143
Wide character in print at pm-979143 line 7, <DATA> line 1.
ă
1
moo@cow~>perl -CO -MYAML::XS pm-979143
ă
1

You can see that only the YAML::XS version is doing UTF-8. YAML::Syck's documentation listed it as deprecated until somewhat recently when it picked up a new maintainer. And JSON(::XS) is also a fine, maybe better, choice. Neither lets you off the hook for knowing what bytes v chars are in play.


Comment on Re: UTF8 with YAML or JSON

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-07-25 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls