Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: issue with readin IO::Uncompress:Gunzip and utf-8

by jeffenstein (Friar)
on Aug 25, 2020 at 11:03 UTC ( #11121075=note: print w/replies, xml ) Need Help??


in reply to issue with reading IO::Uncompress:Gunzip and utf-8

Gzip doesn't seem to store the encoding information, so you'll have to decode() the result.

perl -e ' use IO::Uncompress::Gunzip; use Encode; binmode(STDOUT, ":utf8"); open my $in, "<:utf8", "umlaut"; $_=<$in>; print "Uncompressed: $_ ",ord($_),"\n"; my $gin= IO::Uncompress::Gunzip->new("umlaut.gz"); binmode($gin, ":utf8"); $_=<$gin>; print " Compressed: $_ ",ord($_),"\n"; $_ = decode("utf-8", $_); print " Decoded: $_ ",ord($_),"\n"; '

Output:

Uncompressed: 252 Compressed: ü 195 Decoded: 252

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2020-11-30 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?