Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: UTF-8 and systemIO are not friends anymore (unfortunate)

by tye (Sage)
on Dec 31, 2015 at 00:25 UTC ( [id://1151551]=note: print w/replies, xml ) Need Help??


in reply to UTF-8 and systemIO are not friends anymore

I don't see any problems with your presented statement.

I was rather shocked when I stumbled across the new sysread behavior for UTF-8 streams. It seems rather nonsensical to me, demonstrating a lack of understanding or appreciation of several of the reasons why Perl even has sysread().

One not-yet-published module of mine notes:

At least in some versions of Perl, if a file handle has the ":utf8" encoding layer in place [such as via binmode()], then sysread() does some weird and unfortunate things under the covers beyond just calling the read(2) system call once. This makes 4-argument select() incompatible with sysread() for those versions of Perl (when the ":utf8" layer is used).

[....]

You should probably avoid the ":utf8" layer for file handles you wish to use with 4-argument select().

- tye        

Replies are listed 'Best First'.
Re^2: UTF-8 and systemIO are not friends anymore (unfortunate)
by Anonymous Monk on Dec 31, 2015 at 01:12 UTC
    t seems rather nonsensical to me
    Why? Perl's sysread:
    sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
    (my system's) pread:
    ssize_t pread(int fd, void *buf, size_t count, off_t offset);
    How can it work with anything other than bytes and still call itself sys-something? (even if Perl's pread is actually lseek and read... that doesn't change much wrt utf-8)
      LOL! Shows how much I use sysread... But anyway, the argument about seek stands. But sorry! :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1151551]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found