in reply to How to know if a string has UTF-8?

See is_utf8() in Encode, if you're using Perl 5.8.0 or newer.

Replies are listed 'Best First'.
Re: Re: How to know if a string has UTF-8?
by graff (Chancellor) on May 28, 2003 at 09:09 UTC
    Sorry: not only does "is_utf8" miss the mark in this case, but it looks risky based on how it's described in the Encode man page:
    Messing with Perl's internals The following API uses parts of Perl's internals in the current implementation. As such, they are efficient but may change. is_utf8(STRING [, CHECK]) [INTERNAL] Tests whether the UTF-8 flag is turned on in the STRING. If CHECK is true, also checks the data in STRING for being well-formed UTF-8. Returns true if successful, false otherwise.
    Some folks get nervous when they hear about "messing with perl's internals"...
Re: Re: How to know if a string has UTF-8?
by gmpassos (Priest) on May 28, 2003 at 08:35 UTC
    This is only for the flag of the SCALAR, not for the content (or at least need to have the flag utf8 set on to check the content)! Note, I need to check if the content is UTF-8, not if the SCALAR is internally utf8.

    But thanks for the help.

    Graciliano M. P.
    "The creativity is the expression of the liberty".