$ perl -e 'use open ":locale"; use encoding(latin2); print chr(260), "\n"'
Ą
$ perl -e 'use encoding(latin2); use open ":locale"; print chr(260), "\n"'
"\x{12a9}" does not map to iso-8859-2 at -e line 1.
panic: sv_setpvn called with negative strlen at -e line 1.
Which Perl? With 5.8.5 I get Ą.
"\x{12a1}" does not map to iso-8859-2.
\x{12a1}
$ echo -e '\0241' | perl -e 'use open ":locale"; use encoding(latin2); print
ord(<>), "\n"'
260
$ echo -e '\0241' | perl -e 'use encoding(latin2); use open ":locale"; print
ord(<>), "\n"'
196
$ echo -e '\0241' | perl -e 'use open ":encoding(latin2)"; use
encoding(latin2); print ord(<>), "\n"'
260
$ echo -e '\0241' | perl -e 'use encoding(latin2); use open
":encoding(latin2)"; print ord(<>), "\n"'
260
196 is the first byte of UTF-8 encoding of the Unicode character 260.
I guess something forgot to turn on the UTF-8 flag.
Uhhh. "use encoding(latin2)" hurts my eyes, please use instead e.g.
"use encoding 'latin2'".
With the patch I just sent to perl5-porters(_at_)perl(_dot_)org for Perl 5.8.5,
these all seem to work as you expect. The failure in the second one was
not the case of forgetting utf8, it was in fact one too many utf8s...
--
Jarkko Hietaniemi <jhi(_at_)iki(_dot_)fi> http://www.iki.fi/jhi/ "There is this
special
biologist word we use for 'stable'. It is 'dead'." -- Jack Cohen