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

Re: pack and ASCII

Thread Previous | Thread Next
Eric Brine
January 13, 2012 14:17
Re: pack and ASCII
Message ID:
On Fri, Jan 13, 2012 at 4:45 PM, Leon Timmermans <> wrote:

> On Thu, Jan 12, 2012 at 9:53 PM, Eric Brine <> wrote:
> > I've gathered all I said in one place. It will be my last post on the
> > subject unless you specifically ask me a question ("Eric, ...?")
> > That's a pretty serious problem, but it's easy to alleviate. If C<pack>
> were
> > to downgrade when possible, the correct data will be obtained most of the
> > time despite the two bugs present. I'm for that.
> Shouldn't that be encode instead of downgrade?

No, encoding the output of C<pack> would produce garbage, e.g. C<<
pack("N", 0x80112233) >> would return 5 bytes instead of 4.

Maybe you meanting encoding the input of C<< pack "A" >>, but that would
break C<< pack("A20", $byte) >> and change C<< pack("A20", $text) >> in an
incompatible way.

As previously mentioned, it could be useful to encode using UTF-8, but it
would have to be a different pattern. See JPL's email from eight hours ago
and mine from two hours ago for more on that.

Is there any actual use case where one may want to use pack "a" with
> the current semantics? I can see it for "A", but not for "a".

hum? C<< pack "a" >> has always been very useful. It's used to build C
structs and fixed-width records, for starters.

- Eric

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