Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^8: Text::CSV encoding parse()

by Tux (Abbot)
on Aug 15, 2019 at 07:53 UTC ( #11104509=note: print w/replies, xml ) Need Help??

in reply to Re^7: Text::CSV encoding parse()
in thread Text::CSV encoding parse()

Using the perl internals through Data::Peek's DPeek, you'll see both versions if UTF-8 is in effect without the fragile use of utf8 function calls. It also shows the importance of using utf8 in your example code.

$ perl -MData::Peek -wE'my $data = "Euro symbol: | I \N{U+276 +4}\N{U+FE0F} \N{U+1F42A}"; DPeek $data' PV("Euro symbol: \303\242\302\202\302\254 | I \342\235\244\357\270\217 + \360\237\220\252"\0) [UTF8 "Euro symbol: \x{e2}\x{82}\x{ac} | I \x{2 +764}\x{fe0f} \x{1f42a}"] $ perl -Mutf8 -MData::Peek -wE'my $data = "Euro symbol: | I \N{U+276 +4}\N{U+FE0F} \N{U+1F42A}"; DPeek $data' PV("Euro symbol: \342\202\254 | I \342\235\244\357\270\217 \360\237\22 +0\252"\0) [UTF8 "Euro symbol: \x{20ac} | I \x{2764}\x{fe0f} \x{1f42a} +"] $ perl -Mutf8 -MData::Peek -wE'my $data = "Euro symbol: \xe2\x82\xac | + I \xe2\x9d\xa4\xef\xb8\x8f \xf0\x9f\x90\xaa"; DPeek $data' PV("Euro symbol: \342\202\254 | I \342\235\244\357\270\217 \360\237\22 +0\252"\0)

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^9: Text::CSV encoding parse()
by haukex (Bishop) on Aug 15, 2019 at 08:26 UTC
    without the fragile use of utf8 function calls

    Although you're certainly right that several of the functions from utf8:: should be used with extreme caution (or not at all), AFAIK using is_utf8 to check on the flag for debugging (only!) should be fine. I was just trying to provide a slightly "nicer" debugging output because slugger415 said "I'm not a developer, just a Perl hack, don't grok hexdump or Devel::Peek etc.".

    slugger415: I just wanted to add that I wasn't necessarily suggesting you should try to understand the output, it's also very useful information for us to help you debug.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-03-04 04:22 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (98 votes). Check out past polls.