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

Re: pack and ASCII

Thread Previous | Thread Next
Eric Brine
January 10, 2012 22:36
Re: pack and ASCII
Message ID:
On Tue, Jan 10, 2012 at 5:54 PM, Leon Timmermans <> wrote:

> On Tue, Jan 10, 2012 at 9:17 PM, Eric Brine <> wrote:
> > bytes::length does not return the number of bytes in $foo.
> It seems I define byte as octet of data, and you define it as
> character in a bytestring, which causes confusion (yeah I know, both
> of these definitions suck, but I hope you know what I mean).

I define byte as an octet of data.

You're not even looking at the data but at how Perl stores it.

> Not true. Those aren't exclusive. Right now, both DWIM. The former returns
> exactly one byte. The latter returns exactly one character.

>  They don't DWIM for me. I mean to get a bytestring as result.

If you have code that requires a UTF8=0 string specifically, it is buggy.
Specifically, it suffers from the Unicode bug. You are probably using SvPV
without looking at the SvUTF8. The solution is simple: Use SvPVbyte instead.

> You still didn't say what you think the two formats should do.

>  I want reliable byte semantics when I'm using pack. If other people
> want character semantics that should be separate from this. This
> polymorphism is madness.

I do no understand that answer at all.

What should pack("A*", $_) return for a byte, and what should it return for
a non-byte?

- Eric

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