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

Re^2: UTF8 Validity

by menolly (Hermit)
on Feb 21, 2008 at 19:57 UTC ( #669372=note: print w/replies, xml ) Need Help??

in reply to Re: UTF8 Validity
in thread UTF8 Validity

Ah. I tried it based on this reply, in the other thread. Is there a module/regex/etc. that I can use to detect non-utf8 data in a string?

Replies are listed 'Best First'.
Re^3: UTF8 Validity
by Juerd (Abbot) on Feb 21, 2008 at 20:02 UTC

    Just try to decode something as UTF-8. If that fails, fall back to something else.

    For example:

    $foo = eval { decode("UTF-8", $foo, Encode::FB_CROAK) } || decode("CP1252", $foo);

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2016-10-21 20:40 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (290 votes). Check out past polls.