in reply to
Re^3: text encodings and perl
in thread text encodings and perl
You seem to equate "is a text string" with "is_utf8 returns true". That's wrong.
No. I don't. I just said, that when "is_utf8" returns true, then perl thinks that it knows which is the encoding of text in the string. 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". Of course, text string stays text string independent of is_utf8 flag. Just what perl can do with this string differs.
Just to illustrate it. Try to use in your examples russian letters written as UTF-8 strings and then apply "lc" to those strings. Ie.
$ perl -CS -Mstrict -wE 'say lc "\xd0\xa7"'
$ perl -CS -Mstrict -wE 'say "\xdo\xa7"'
This displays garbage instead of russian letter "Ч". Change it to
$ perl -CS -Mstrict -MEncode -wE 'say lc Encode::decode("UTF-8", "\xd0\xa7")'
$ perl -CS -Mstrict -MEncode -wE 'say Encode::decode("UTF-8", "\xdo\xa7")'
And you'll get the correct output. In fact, in your examples perl effectively
calls the Encode::decode but with parameter "Latin1" instead of "UTF-8", that
is why your letter (from Latin1) is displayed correctly, but mine (UTF-8) is not.