Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

utf8::is_utf8 valid introspection?

by McA (Priest)
on Jul 10, 2013 at 13:32 UTC ( #1043473=perlquestion: print w/ replies, xml ) Need Help??
McA has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

there is much stuff out there for utf8::is_utf8. My question: Is this a valid/accepted/reliable function to introspect a perl string? Is it valid to rely on the upgrading semantics when I concatenate a utf8 flagged string with an unflagged one?

Best regards

Comment on utf8::is_utf8 valid introspection?
Download Code
Replies are listed 'Best First'.
Re: utf8::is_utf8 valid introspection?
by dave_the_m (Prior) on Jul 10, 2013 at 15:13 UTC
    Code that needs to use utf8::is_utf8 (apart from for debugging purposes) is, in general, likely to be buggy. Most of the time your code shouldn't need to care what internal format perl's currently using to store strings.

    Except of course for "the Unicode bug", where the state of the utf8 flag on strings effects things like regexes for chars in the range 0x80..0xff. This has been reduced in more recent perls by the addition of things like the //a match modifier.


Re: utf8::is_utf8 valid introspection?
by ikegami (Pope) on Jul 11, 2013 at 00:23 UTC

    If you need to work around a bug, just use




    to get the the string in the expected storage format (regardless of the current storage format).

    The only use I can think of for utf8::is_utf8 is for debugging, but I use Devel::Peek's Dump when I want to peek at a scalar's internals.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1043473]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2015-10-08 18:01 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (222 votes), past polls