develooper Front page | perl.perl5.porters | Postings from November 2000

Re: PerlIO - what next ?

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
November 8, 2000 07:22
Subject:
Re: PerlIO - what next ?
Message ID:
200011081522.PAA08160@mikado.tiuk.ti.com
Nicholas Clark <nick@ccl4.org> writes:
>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"

Yes. I was mistaken in thinking only top layer determined that.

>{
>  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.

Fine - that was my intuition too.

>
>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;

Okay - but can we discuss what args you pass to open->import ?


>
>Nicholas Clark
-- 
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.


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