in reply to Guess between UTF8 and Latin1/ISO-8859-1

In perluniintro, under the "Questions with Answers" section, there is an example of how to check if a string contains Unicode. It comes with a big warning that you really don't want to do this . . .

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Guess between UTF8 and Latin1/ISO-8859-1
by Jenda (Abbot) on Jan 21, 2004 at 22:04 UTC

    It seems you meant the response to the "How Do I Know Whether My String Is In Unicode?" question, right? Well I don't care whether Perl thinks the string is unicode (I know it does not), I want to know whether the string of bytes is "could be" UTF-8. Anyway the later answers seem to be what I need. I did try the pack() solution and it seems to be working fine.

    I'll try several ways suggested in that manpage and by other responders and come back with some benchmarks :-)

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature