Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2018-06-21 10:44 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.