Front page | perl.perl5.porters |
Postings from January 2012
Re: pack and ASCII
Thread Previous
|
Thread Next
From:
demerphq
Date:
January 9, 2012 08:36
Subject:
Re: pack and ASCII
Message ID:
CANgJU+VWo=D=4LmajhysBn9cWAn5USp3HpyhFb6pKDuhUvjaBw@mail.gmail.com
On 9 January 2012 17:27, Leon Timmermans <fawaka@gmail.com> wrote:
> On Mon, Jan 9, 2012 at 4:46 PM, John P. Linderman (jpl)
> <jpl@research.att.com> wrote:
>> I was more concerned that the documentation suggested that pack/unpack would
>> only work on ASCII strings, not on arbitrary strings. Granted, the length
>> associated with "a" and "A" might need some amplification, similar to what
>> is there for the "length" function. If pack/unpack cannot deal with
>> non-ASCII strings (I know they work ok for bytes with the high-order bit
>> on), then what happens when the corresponding argument includes non-ASCII
>> characters? -- jpl
>
> Well, your question led me to discover what I consider to be a bug:
>
> perl -E 'use utf8; my $packed = pack "A*", "ţ"; say utf8::is_utf8($packed);'
> 1
Interesting. I think I agree that this is a bug.
> Personally, it makes no sense to me to pass pack "A" a character
> string in the first place, if only because it relies on the internal
> encoding of perl for its result, but to return a character string is
> just plain wrong.
A and in particular Z are there so you can easily create data
structures in Perl which can be passed into C/XS.
cheers,
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
Thread Previous
|
Thread Next