develooper Front page | perl.perl5.porters | Postings from January 2012

Re: pack and ASCII

Thread Previous | Thread Next
Leon Timmermans
January 9, 2012 08:27
Re: pack and ASCII
Message ID:
On Mon, Jan 9, 2012 at 4:46 PM, John P. Linderman (jpl)
<> 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);'

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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About