in reply to Re^2: Understanding pack and unpack changes for binary data between 5.8 and 5.10
in thread Understanding pack and unpack changes for binary data between 5.8 and 5.10
The problem is that when I do a length on the return value. Of course I should have used "bytes", but as I said, the return value is a binary string, so returning a length in utf8 characters is strange.
And what's great with this bug, is that you only see it when the original string has multi-bytes characters or when it is long enough. :)
And what's great with this bug, is that you only see it when the original string has multi-bytes characters or when it is long enough. :)
use Encode qw/_utf8_on/; my $a="bj\xc3\xb6rk"; _utf8_on($a); my $binarystring=pack("V/a*", $a); warn length $binarystring; warn bytes::length $binarystring; my $b="b"x1000; _utf8_on($b); my $binarystring2=pack("V/a*", $b); warn length $binarystring2; warn bytes::length $binarystring2;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Understanding pack and unpack changes for binary data between 5.8 and 5.10
by ikegami (Patriarch) on Mar 12, 2009 at 16:59 UTC | |
by squentin (Sexton) on Mar 13, 2009 at 13:59 UTC | |
by ikegami (Patriarch) on Mar 13, 2009 at 15:10 UTC | |
by ikegami (Patriarch) on Mar 13, 2009 at 16:10 UTC | |
by squentin (Sexton) on Mar 13, 2009 at 21:26 UTC | |
by ikegami (Patriarch) on Mar 13, 2009 at 21:44 UTC |
In Section
Seekers of Perl Wisdom