This is wrong, it has nothing to do with the UTF8 flag, see demo program below. The reason why open A in your example creates a file with a name that is broken for display purposes only¹ is because you (implicitly) used an encoding (namely, Latin1) that does not agree with the encoding of the filesystem² (namely, UTF-8).

If a programmer does the straight-forward thing that comes to mind, namely just using a string, not even bothering to encode to octets, then there is no problem. Both strings and UTF-8 encoded octet sequences work. I personally haven't even run into the problem during the last ten years because it requires special action to set oneself up for failure in order to trigger.

To come back to the topic expressed in the root post, I think nothing needs to be done for Posix. This is a Windows only bugfix.

¹ The big difference to the Windows shitshow where system calls do not work and return error messages, on Posix they do work even if you somehow fuck up the encoding. The file will exist, will be enumerable, will create a filehandle you can operate on, merely the name will display wrong.

² De jure the encoding of a Posix filesystem is unknown and unknowable, but de facto it is UTF-8. I remember dwheeler is doing work to get UTF-8 as default into the next version of the standard, but I can't find the relevant document on the Web.

use 5.026;
use utf8;
use Devel::Peek qw(Dump);

my $string = 'string-año';
#   FLAGS = (POK,IsCOW,pPOK,UTF8)
#   PV = 0x12f4760 "string-a\303\261o"\0 [UTF8 "string-a\x{f1}o"]
my $octets_latin1 = "octets-latin1-a\x{f1}o";
#   FLAGS = (POK,IsCOW,pPOK)
#   PV = 0x12f4420 "octets-latin1-a\361o"\0
my $octets_utf8 = "octets-utf8-a\x{c3}\x{b1}o";
#   FLAGS = (POK,IsCOW,pPOK)
#   PV = 0x12ebb00 "octets-utf8-a\303\261o"\0

my $fh;                         # ↓ displays in shell as: ↓
open $fh, '>', $string;         # string-año
open $fh, '>', $octets_latin1;  # 'octets-latin1-a'$'\361''o'
open $fh, '>', $octets_utf8;    # octets-utf8-año

In reply to Re^2: RFC: system calls on Unicode filesystem by daxim
in thread RFC: system calls on Unicode filesystem by daxim

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.