I can see what the OS passes to perl as "char *argv[]", and also what Perl actually stores in @ARGV, with the following:
# x.pl use v5.28; use Data::HexDump; use Encode qw(encode decode); my $a0 = $ARGV[0]; my $a0d = decode( q(UTF-8), $a0 ); say HexDump($a0); say HexDump($a0d); open my $fh, q(>), $a0; open my $fhd, q(>), $a0d; sleep 99; # shell aa=$(perl -CSDA -we 'print 1 . chr(0xb1) . chr(0x155) . 2') perl -w x.pl "$aa" & ls -rt xxd /proc/`pidof perl`/cmdline

This also creates a file (or two) with a "funny" name.

Now, on my particular system, it seems that perl starts with a UTF-8 encoding of "$aa" in its /proc/cmdline (i.e. the C "char *argv[]"), and that Perl @ARGV corresponds verbatim to C argv[].

It also seems that for open(), both byte-array strings, and also strings with one unicode codepoint / char (as obtained via decode) create the same filename. Maybe Perl does an implicit utf8 decode()?

But this is just an experiment on a particular setup. I'm not really sure (1) what Perl actually does on startup (does it process its C argv, maybe according to locale), (2) what open() is supposed to take, and (3) what readlink(), readdir() etc are supposed to return. What are the rules?

EDIT: fixed second perl invocation


In reply to how are ARGV and filename strings represented? by almr

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.