Tommy has asked for the wisdom of the Perl Monks concerning the following question:
As of Perl 5.23, using :utf8 binmode on filehandles opened with sysopen causes a warning (or at least it does as soon as someone tries to syswrite/sysread).
From what I read in perldoc perlport -- it's a portability issue because sysseek'ing and tell'ing get garbled and confused. Makes perfect sense why you'd want to avoid it.
I've written the following statement as part of a documentation effort, based on my understanding of the new deprecation, and I wonder if any of it is inaccurate or even plain less-than-ideal. I have asked the same question to the perl5 core hackers on IRC, but while I'm waiting on a response from them, I'm still interested in what you think about it.
Specifically because I'm not a C expert or perl-guts guru, I want to be doubly sure this is right before I start disseminating it:
As a rule of thumb, and to avoid confusion, stick to the use of utf8 binmode for unicode text streams only, or if you don't have a compelling need for that, you can use lower level system IO via sysopen/sysread/syswrite and be done with it. In the end, bytes at rest in files are just bytes. If you aren't trying to encode your text as UTF-8 strict, you can safely use system IO without adding any additional IO disciplines/layers and you should be fine. With system IO, no translations will occur on your input/output streams that could cause your file content to be mangled. You can write raw text or even binary streams and never worry.
UPDATE: If you're reading this on the front page, please click on in-- the discussion on this post is a worthwhile read, and contains corrections.
A mistake can be valuable or costly, depending on how faithfully you pursue correction
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: UTF-8 and systemIO are not friends anymore (unfortunate)
by tye (Sage) on Dec 31, 2015 at 00:25 UTC | |
by Anonymous Monk on Dec 31, 2015 at 01:12 UTC | |
by Anonymous Monk on Dec 31, 2015 at 01:29 UTC | |
Re: UTF-8 and systemIO are not friends anymore
by Anonymous Monk on Dec 31, 2015 at 01:07 UTC | |
by Anonymous Monk on Dec 31, 2015 at 01:49 UTC | |
by Tommy (Chaplain) on Jan 02, 2016 at 18:54 UTC | |
by Anonymous Monk on Jan 03, 2016 at 18:22 UTC | |
by Tommy (Chaplain) on Jan 04, 2016 at 16:15 UTC | |
by Tommy (Chaplain) on Jan 02, 2016 at 19:51 UTC |