how do I make the records output through Data::Dumper come out as "Particípio Passado" instead of "Partic\x{c3}\x{ad}pio Passado"?
The string isn't "Particípio Passado"; it's the UTF-8 encoding of "Particípio Passado". If you had "Particípio Passado", Data::Dumper would print one of the following (depending on a couple of factors):
$VAR1 = "Particípio Passado"; $VAR1 = "Partic\x{ed}pio Passado"; $VAR1 = "Partic\355pio Passado";
(The first would only show up correctly if you properly encode your output. We'll get back to that.)
If you're using JSON::XS, this problem would arise if you didn't call ->utf8.
my $json_parser = JSON::XS->new->utf8; my $data = $json_parser->decode($json_string);
If I do a normal print of the keys, they come right
Given that the string is wrong, that indicates there are other problems. (i.e. Two wrongs made a right.)
First, I bet your Perl source file is encoded using UTF-8, but you didn't tell Perl that using
use utf8;
Secondly, I bet you have a UTF-8 terminal, but you didn't tell Perl that using one of
use open ':std', 'locale'; use open ':std', ':encoding(UTF-8)';
In reply to Re: JSON, Data::Dumper and accented chars in utf-8
by ikegami
in thread JSON, Data::Dumper and accented chars in utf-8
by silentius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |