I'm confused by your code, what is it supposed to demonstrate? perlunitut: Unicode in Perl warns against using is_utf8, so I wouldn't use it
Consider
when viewed as Windows-1252 it is À$ perl -le " print chr hex q/C0/ " | od -tx1 0000000 c0 0d 0a 0000003
And this
when viewed as Windows-1252 it is À but viewed as UTF-8 it is À$ perl -le " binmode STDOUT , q/:utf8/; print chr hex q/C0/ " | od -tx +1 0000000 c3 80 0d 0a 0000004
And this
when viewed as Windows-1252 it is � but viewed as UTF-8 it is �$ perl -MEncode -le " print decode(q/utf8/, chr hex q/C0/ )" | od -tx1 Wide character in print at -e line 1. 0000000 ef bf bd 0d 0a 0000005
If you search for ef bf bd you'll see lots of questions about this erroneous conversion
So if you want to treat chr 192 ( perl -le " print hex q/C0/ " ) as unicode you have to encode it, because characters 0 to 255 are also valid Latin-1, they are not utf8
$ perl -le " print chr hex q/C0/ " |od -tx1 0000000 c0 0d 0a 0000003 $ perl -le " print chr 255 " |od -tx1 0000000 ff 0d 0a 0000003 $ perl -le " print chr 256 " |od -tx1 Wide character in print at -e line 1. 0000000 c4 80 0d 0a 0000004
Or, if you want chr 192 to return unicode, use encoding pragma ( utf8 pragma doesn't affect chr )
$ perl -le " use encoding q/utf8/; print chr 192 " |od -tx1 0000000 c3 80 0a 0000003
In reply to Re^4: Bug in Template?
by Anonymous Monk
in thread Bug in Template?
by packetstormer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |