No such thing as a small change | |
PerlMonks |
Re^5: DWIM with non ASCII charactersby almut (Canon) |
on May 07, 2010 at 15:10 UTC ( [id://838923]=note: print w/replies, xml ) | Need Help?? |
This only works because you have a UTF-8 terminal, but haven't told Perl about it. In other words, Perl is treating the UTF-8 encoded byte sequence in the source code - which represents the Unicode char U+00F1 (ñ) - as two separate bytes, and passes them on as is (i.e. UTF-8 encoded) to the terminal, which consequently displays the character correctly. Perl internally, however, you don't have a character string, so you cannot properly match, etc.:
The string comparison outputs:
and the byte/char values print as (in a UTF-8 terminal):
Note that as soon as you tell Perl that your terminal is UTF-8 (with binmode), the byte string stops printing correctly, because Perl is now converting the two byte/latin1 chars c3 and b1 to the respective UTF-8 sequences c3 83 and c2 b1, which display as two separate characters...
In Section
Seekers of Perl Wisdom
|
|