in reply to
Re^6: 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
Ok, I'll try to be clear this time :)
What I wanted is write the string encoded in utf8, and the length, in bytes, of the binary string resulting from pack.
So I was using :
my $p=pack "V/a*", $s;
my $l=length $p;
When I should have been using :
use Encode qw/encode/;
my $p=pack "V/a*", encode('utf8',$s);
my $l=bytes::length $p;
# using bytes::length just to be sure, $p shouldn't have its utf8 flag
+ on, but in case it does...
Thinking about it a little more, I think what is disturbing me is that the 'a' in the pack format can be a multi-bytes character. And more generally, the idea that utf8 strings are strings of multi-bytes characters, rather than strings of bytes in utf8 encoding.
perl 5.10's pack behavior does seem to make more sense now.