develooper Front page | perl.perl5.porters | Postings from May 2003

Re: Meaning of sysread()

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
May 21, 2003 04:45
Subject:
Re: Meaning of sysread()
Message ID:
20030521114459.GT110212@kosh.hut.fi
I was responsible for the wording change in perlfunc (change #13146,
a year and a half ago).  So I'm biased, but I still do think what it
says now for sysread() is "correct" and "fine":

First:

> Attempts to read LENGTH I<characters> of data into variable SCALAR
> from the specified FILEHANDLE, using the system call read(2)

For non-Unicode-caring people the difference between "bytes" and
"characters" does not exist.

Then:

> Note the I<characters>: depending on the status of the filehandle,
> either (8-bit) bytes or characters are read.  By default all
> filehandles operate on bytes, but for example if the filehandle has
> been opened with the C<:utf8> I/O layer (see L</open>, and the C<open>
> pragma, L<open>), the I/O will operate on characters, not bytes.

So to answer your question: bytes.  Always has done, still does....
EXCEPT when the filehandle has been marked :utf8, in which case
Unicode characters are read, even with sysread().  (I think leaving it
otherwise would be a mess, people having to parse UTF-8 manually.)

I think I like of the suggestions most the PerlIO_syslayer() one.
There is already enough rope out there :-)

-- 
Jarkko Hietaniemi <jhi@iki.fi> http://www.iki.fi/jhi/ "There is this special
biologist word we use for 'stable'.  It is 'dead'." -- Jack Cohen

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