Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Data::Dumper and utf8

by brycen (Monk)
on Aug 13, 2010 at 21:28 UTC ( [id://855007]=note: print w/replies, xml ) Need Help??


in reply to Data::Dumper and utf8

The difference with $Data::Dumper::Useperl = 1; is related to strings that can be represented entirely without utf8. On ingest eval makes the usual perl heuristic about utf8, and gets it wrong:
#!/usr/bin/perl -w use utf8; # so source code is utf-8 encoded use Data::Dumper; $data1 = 'ä ☺'; # a-umlaut, space, smiley $data2 = 'ä '; # a-umlaut, space, space $Data::Dumper::Useperl = 1; $dump1 = Dumper( $data1 ); print $dump1; $dump2 = Dumper( $data2 ); print $dump2; print "\n"; $Data::Dumper::Useperl = 0; $dump1 = Dumper( $data1 ); print $dump1; $dump2 = Dumper( $data2 ); print $dump2; print "\n";

Output

$VAR1 = "\x{e4} \x{263a}"; $VAR1 = 'ä '; $VAR1 = "\x{e4} \x{263a}"; $VAR1 = "\x{e4} ";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-25 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found