Saturday, January 29, 2011

perl: difference between use encoding 'utf8' and use utf8

`use utf8;` tells the compiler that the script is written 
in UTF-8. That's all it does.

`use encoding 'utf8'` tells it the srcipt is in UTF-8, 
its literal strings are in UTF-8, and STDIN, STDOUT, 
and DATA are in UTF-8.

$ perl -Mutf8 -e'print"\x{2022}\n";'
Wide character in print at -e line 1.
•
$ perl -Mencoding=utf8 -e'print"\x{2022}\n";'
•

No comments: