Front page | perl.perl5.porters |
Postings from November 2000
Re: PerlIO - what next ?
Thread Previous
|
Thread Next
From:
Nicholas Clark
Date:
November 8, 2000 06:24
Subject:
Re: PerlIO - what next ?
Message ID:
20001108142416.A98736@plum.flirble.org
On Wed, Nov 08, 2000 at 01:50:06PM +0000, Nick Ing-Simmons wrote:
> This means knowing what it "should" look like to perl5:
>
> Do you want getc($fh) return character or a byte depending on the handle's
> top "layer" ?
>
> Likewise does
>
> $count = read($fh,$buffer,10);
>
> read 10 chars or 10 bytes depending on mode ?
What do you mean by mode? "sum of effects of layers on the handle"
{
use utf8; # And if I understand it correctly this will become a no-op
Surely there's no difference between a byte and a character?
}
> How do you want I open a file which is utf8 or shift-jis or whatever?
>
> What should "binmode" mean now we have layers?
I'd expect [my opinion] that getc($fh) gets scalar of length 1, and the read
call returns a scalar of length 10.
A given (disk) file is treated as utf (and faulted if bad utf?) and stuffed
into a scalar with characters > 255 if there's
(a layer on the handle to convert the raw bytestream to utf) ||
(the handle is using an OS API that returns utf)
If there's no layer doing conversion then the raw disk bytes end up in
a perl scalar which only contains characters < 256 independent of
whether that byte sequence is a valid utf encoding (of some other
sequence)
I'd agree with Simon that what layers get stacked is based on use open;
Nicholas Clark
Thread Previous
|
Thread Next