Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Guessing encode text file

by aitap (Curate)
on Jan 20, 2014 at 19:18 UTC ( [id://1071370]=note: print w/replies, xml ) Need Help??


in reply to Guessing encode text file

Wouldn't it be more handy to use the error fallback options of the decode function from the standard module Encode? For example, you can set it to throw exception if text cannot be decoded as UTF-8 and catch the exception:
my $characters = eval { decode utf8 => $bytes, Encode::FB_CROAK }; unless (defined $characters) { warn "$filename does not contain valid UTF-8 data, skipping"; next FILE; } # INSERT INTO ...
(untested)

Replies are listed 'Best First'.
Re^2: Guessing encode text file
by karlgoethebier (Abbot) on Jan 20, 2014 at 19:39 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 07:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found