Venerable Monks,

Please enlighten me, for I am in the dark even after a few hours reading the modules' documentation and experimenting.

I have this code:

while ($line = <IN>) { $strut = from_json($line); print Dumper($strut) . "\n"; }

The file I am reading from contains JSON records and is a text/plain; charset=utf-8 text file.

The problem is some records in that file have keys that have accented chars, namely "Particípio Passado" and when I output those records through the Data::Dumper module they come as:

"Partic\x{c3}\x{ad}pio Passado" => [ 'abasinado' ],

If I do a normal print of the keys, they come right, they come as "Particípio Passado", without the \x{c3}\x{ad} encoding.

Also, with this code: print $strut->{'Particípio Passado'}->[0]."\n"; I can access the records' contents, so the keys seem properly encoded.

But when I output through Data::Dumper they come as "Partic\x{c3}\x{ad}pio Passado", so, venerable monks, my question is: 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"?

Gratefully, humbly and respectfully I appreciate and thank any enlightenment on this.


In reply to JSON, Data::Dumper and accented chars in utf-8 by silentius

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.