RE: Unicode filenames on Windows with Perl >= 5.8.2

[email protected] ("Jan Dubois")
Newsgroups perl.unicode
Message-ID <[email protected]>
> I'm trying to figure out if I can handle Unicode filenames on 
> Windows using Perl 5.8.4, and if so, how.

[...]
 
> So my question is: How can I deal with these files?
> 
> I've tried using Perl scalars containing UTF-8, UTF-16LE and 
> UTF-16BE encodings of the filenames, but none of them work 
> either.  Indeed, if I try to write a new file with a name 
> constructed in those ways, then the name of the file actually 
> created is simply the sequence of bytes that make up those encodings.

I don't think this is possible from Perl code right now.  You need to
call CreateFileW() to open a file with a Unicode name.  If you want to
hack something, then I would suggest to write a little XS module that
just swaps out the file handle in a PerlIO* structure.  Look at
PerlIOWin32_open() in win32/win32io.c to see how Perl currently opens
a file.

Another quick-and-dirty "solution" would be to build a custom Perl
by hacking win32/win32.h.  If you change the USING_WIDE definition
to "1" then you end up with a version of Perl that has the old "-C"
behavior hardcoded.  Remember that this is not really compatible with
Perl's Unicode handling.

Cheers,
-Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.