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

Re: UTF8 Validity

by Juerd (Abbot)
on Feb 21, 2008 at 19:48 UTC ( #669370=note: print w/ replies, xml ) Need Help??


in reply to UTF8 Validity

utf8::valid checks the internal consistency for a string. On the outside, it does not have anything to do with UTF-8 encoding at all.


Comment on Re: UTF8 Validity
Re^2: UTF8 Validity
by menolly (Hermit) on Feb 21, 2008 at 19:57 UTC
    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?

      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2015-07-06 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls