Front page | perl.perl5.porters |
Postings from January 2012
Re: pack and ASCII
Thread Previous
|
Thread Next
From:
Jesse Luehrs
Date:
January 10, 2012 12:58
Subject:
Re: pack and ASCII
Message ID:
20120110205832.GN23629@tozt.net
On Tue, Jan 10, 2012 at 03:17:26PM -0500, Eric Brine wrote:
> On Tue, Jan 10, 2012 at 7:43 AM, Leon Timmermans <fawaka@gmail.com> wrote:
>
> > On Tue, Jan 10, 2012 at 2:17 AM, Eric Brine <ikegami@adaelis.com> wrote:
> > > You can count on «pack "A1", $foo» never return more than one byte.
> > >
> > > You can't count on the character returned by «pack "A1", $foo» to be a
> > byte,
> > > though.
> >
> > Only one of those two can be true, and it isn't the former:
> >
> > perl -E 'no bytes; use utf8; my $foo = pack "A1", "ţ"; say
> > bytes::length($foo)'
> > 2
> >
> bytes::length does not return the number of bytes in $foo.
Then what does it return? What does that '2' represent?
> > C<< pack "A1" >> will never return more than one octet.
> >
>
> If only that were the case.
> >
>
> Then give an example where it doesn't.
It doesn't in the example given above.
$ perl -MDevel::Peek -E'use utf8; my $foo = pack "A1", "ţ"; Dump($foo)'
SV = PV(0x2360160) at 0x2376ee8
REFCNT = 1
FLAGS = (PADMY,POK,pPOK,UTF8)
PV = 0x237f7c0 "\305\243"\0 [UTF8 "\x{163}"]
CUR = 2
LEN = 16
That is clearly two octets - \305 and \243, unless you're using some
other definition of "octet".
Or am I misunderstanding something here?
-doy
Thread Previous
|
Thread Next