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

Re: pack and ASCII

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
January 9, 2012 08:27
Subject:
Re: pack and ASCII
Message ID:
CAHhgV8iskQ70xgYc9BGD_SbxaAFLRLL-oWUKYMk99_VuEs6wbQ@mail.gmail.com
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

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.

Leon

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About