in reply to Re^4: text encodings and perl
in thread text encodings and perl
If the return value is "false", then perl does not know which encoding is really used, so it may use Latin1, or whatever is found working "most of the time"
I'm curious how you came to that conclusion. For any text operation, perl has to assume an encoding. It uses UTF-8 if the utf8 flag is present on the string, and Latin 1 otherwise (assuming you didn't mess with locales). It has no notion of "working" and "most of the time".
I'm well aware of when I need to decode, and when not. And my point was that deciding this question based on the return value of is_utf8 is wrong.
In fact, in your examples perl effectively calls the Encode::decode but with parameter "Latin1" instead of "UTF-8"
It doesn't. Because Latin-1 strings themselves can be perfectly fine text strings.
If you don't believe me, add a warn to the Encode::decode() function of your local perl installation. You'll observe no such call.