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.

Tommy
A mistake can be valuable or costly, depending on how faithfully you pursue correction

In reply to UTF-8 and systemIO are not friends anymore by Tommy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.