Bob Hallissy wrote in perl.unicode : > Am I doing something wrong or is this a bug: > > use strict; > my $p; > foreach $p (qw (C U C)) > { > my $s = pack($p, 200); > print "pack('$p', 200): is_utf8=" . (utf8::is_utf8($s) ? 'yes' : 'no ') > . "\t$s\t" . join(',', unpack('C*', $s)) . "\n"; > } > > Generates the following output: > > pack('C', 200): is_utf8=no « 200 > pack('U', 200): is_utf8=yes « 195,136 > Wide character in print at T:\test2.pl line 8. > pack('C', 200): is_utf8=yes « 200 > > Specifically, the first and last ought to be the same, and I shouldn't be > getting that error. > > Seen on perl 5.8.3, 5.8.6 and 5.8.7. E.g., my current perl -v: > This is perl, v5.8.7 built for MSWin32-x86-multi-thread > (with 7 registered patches, see perl -V for more detail)
This is fixed in the development branch of perl (5.9.x). Something probably goes wrong with the localisation of UTF-8 magic. The next 5.8.x release may have this bug fixed.