If I do not use Data::Dumper, I obtain this:$ perl -E ' use utf8; use Data::Dumper; my $data = qq( { "cat" : "text – abcd" } ); print Dumper($data); ' $VAR1 = " { \"cat\" : \"text \x{2013} abcd\" } ";
i.e. a warning but the right output. As previously mentioned by Corion, it is a feature of Data::Dumper to display the UTF-8 escape sequences.$ perl -E 'use utf8; my $data = qq( { "cat" : "text – abcd" } ); say $data ' Wide character in say at -e line 4. { "cat" : "text – abcd" }
Using binmode, as I already told you several days ago in an answer to your previous post with the same content, I no longer have any warning:
Have you tried binmode?$ perl -E 'use utf8; my $data = qq( { "cat" : "text – abcd" } ); binmode STDOUT, ":utf8"; say $data; ' { "cat" : "text – abcd" }
In reply to Re: malformed UTF-8 character in JSON string in perl
by Laurent_R
in thread malformed UTF-8 character in JSON string in perl
by Yllar
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |