Problems? Is your data what you think it is? | |
PerlMonks |
Re: Potential bug in chrby roboticus (Chancellor) |
on Feb 05, 2018 at 00:58 UTC ( [id://1208450]=note: print w/replies, xml ) | Need Help?? |
The use utf8; directive only tells perl that you're using Unicode in your source code file. It doesn't tell perl to perform any automatic conversions. The documentation (perldoc -f chr) explicitly states that chr doesn't encode the characters 128..255 (which includes 0xB0) as UTF-8 internally for backward compatibility reasons. However, if you tell perl to add the utf8 encoding to the output stream, then the 0xb0 will be encoded on output as you want:
Update: I'm not really all that comfortable with Unicode stuff, so reaching for Devel::Peek, I fabricobbled this little thing together:
This shows that if you happen to join a byte-oriented string with a unicode string in perl, the result will be a unicode string. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|