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)';
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.