Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: By the shine on my bald pate, I dislike this encoding stuff

by Anonymous Monk
on Mar 06, 2018 at 11:09 UTC ( [id://1210397]=note: print w/replies, xml ) Need Help??


in reply to By the shine on my bald pate, I dislike this encoding stuff

open (ORDERFILE, '<:encoding(UTF-8)', $emailfile) or return (@err, "Co +uld not open order email file: $emailfile"); #... my $filedata = <ORDERFILE>; #... eval { my $utf8 = decode("utf8", $filedata, Encode::FB_CROAK ) };

First you're applying an IOLayer to a filehandle to obtain characters decoded from UTF-8, then you additionally decode unicode characters as if they were UTF-8 bytes. If this is working, it's by chance (i.e. when reading ASCII-only files).

You should either open with :encoding(UTF-8) (but then you'll get warnings on non-UTF-8 text) or open without the IOLayer and do the decoding manually with FB_CROAK option.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found