perl-unicode

Re: pack('C'...) sets UTF8 flag

2005-07-07 02:26:25
Followup: we do *not* see this failure if we flatten the loop, e.g:

use strict;
my $s ;
$s = pack('C', 200);
print "pack('C', 200): is_utf8=" . (utf8::is_utf8($s) ? 'yes' : 'no '). 
"\t$s\t" . join(',', unpack('C*', $s)) . "\n";
$s = pack('U', 200);
print "pack('U', 200): is_utf8=" . (utf8::is_utf8($s) ? 'yes' : 'no '). 
"\t$s\t" . join(',', unpack('C*', $s)) . "\n";
$s = pack('C', 200);
print "pack('C', 200): is_utf8=" . (utf8::is_utf8($s) ? 'yes' : 'no '). 
"\t$s\t" . join(',', unpack('C*', $s)) . "\n";

The failure (as below) occurs on Windows, Linux, and OSX.

Bob

On 2005-07-06 03:43:50 PM "Bob Hallissy" wrote:

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)

Copyright 1987-2005, Larry Wall

Binary build 813 [148120] provided by ActiveState
http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Jun  6 2005 13:36:37

TIA,

Bob


<Prev in Thread] Current Thread [Next in Thread>