perl-unicode

Re: [FYI] use encoding 'non-utf8-encoding'; use CGI;

2002-10-02 07:30:05
On Wednesday, Oct 2, 2002, at 21:51 Asia/Tokyo, Jarkko Hietaniemi wrote:
However, I will need to stare at your example some more, since
for simpler cases I think tr/// *is* obeying the 'use encoding':

use encoding 'greek';
($a = "\x{3af}bc\x{3af}de") =~ tr/\xdf/a/;
print $a, "\n";

This does print "abcade\n", and it also works when I replace the \xdf
with the literal \xdf.

I can explain that. "\x{3af}bc\x{3af}de" is is a string literal so it gets encoded. however, my example in escaped form is;

  $kana =~ tr/\xA4\xA1-\xA4\xF3/\xA5\xA1-\xA5\xF3/

  which does not get encoded.  the intention was;

  $kana =~ tr/\x{3041}-\x{3093}/\x{30a1}-\x{30f3}/

  That's why

  eval qq{ $kana =~ tr/\xA4\xA1-\xA4\xF3/\xA5\xA1-\xA5\xF3/ }

works because \xA4\xA1-\xA4\xF3 and \xA5\xA1-\xA5\xF3 are converted. to \x{3041}-\x{3093} and \x{30a1}-\x{30f3}, respectively.

Dan