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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|