http://www.perlmonks.org?node_id=645255


in reply to Re^3: Unicode substitution regex conundrum
in thread Unicode substitution regex conundrum

"the" internal format for Unicode strings is actually two different formats: ISO-8859-1 and UTF8. As an optimization, Perl may use ISO-8859-1 even though the original source was UTF-8.

Encode::_is_utf8 (not encode::is_utf8) will return true if the string is internally encoded as UTF8, and can return false even though you properly decoded.

Recommendation: do not look at the UTF8 flag. It is next to useless, except for internals debugging and performance tweaking.

Pretend that the UTF8 flag does not exist.

Do not use Encode::_is_utf8 (it is prefixed with an underscore for a reason: you should not have to use this in normal code).

Really, Perl's Unicode strings may be encoded as *ANYTHING* internally. Don't look at the internal buffer, unless you really want to mess with the internals. You do not need to know the internals for simple text processing, as is the case in the OP's problem.