Keep It Simple, Stupid | |
PerlMonks |
Re: Accent file names issueby vr (Curate) |
on Sep 20, 2017 at 13:18 UTC ( [id://1199737]=note: print w/replies, xml ) | Need Help?? |
To add to link jahero provided, there's "language for non-Unicode programs" in Control Panel UI. If your paths use only characters belonging to the "code page" chosen there (as probably case of most people), try this:
Decode from OEMCP, what Windows commands return ('dir', etc.), if you ever need their output. Decode from ACP what Perl's commands ('readdir', etc.) return. And encode to ACP, as above, to reach out from Perl and Unicode to Windows and "non-Unicode programs", e.g. with file tests, file access, copying, etc. Things get more messy if your paths use characters outside of said "code page". If I use opendir/readdir in the "c:\users\someuser\documents" directory it will read "documentação" perfectly No. It's not Unicode string (no utf8 flag) it returns. It's encoded in 'ANSI Code Page'. That's why "-d will work fine". Edit: minor clarifications. + P.S. So, first you encode to ACP an utf-8 path for argument to e.g. opendir, and then decode from ACP each element of readdir's return list, to work in Perl with normal Unicode strings. P.P.S. Oh, dir $parent must be encoded, too, if non-ASCII characters are involved. Let it be an exercise to the reader, to which 'code page' :).
In Section
Seekers of Perl Wisdom
|
|