From: Daniel Berger Date: 2007-02-13T13:25:07+09:00 Subject: Re: win32 unicode filename support? On Feb 12, 6:32 pm, "Bill Kelly" wrote: > Hi, > > I'm reading the win32-utils docs > (http://rubyforge.org/docman/?group_id=85) to try to determine > whether Unicode filename support is provided by the win32-file > module? > > I didn't see much mention of unicode, except in the win32-dir > docs, which mentioned unicode was not yet properly supported > on "create_junction". > > That leads me to suspect maybe unicode *is* supported on the > other routines. > > If so, my next question would be, which encoding format should > the filename string be in when passed to, say, File.open() ? > UTF8 ? Since File.open isn't redefined in win32-file, it won't make a difference one way or the other. :) However, in general I would say that Unicode support is even worse than I originally thought (though, no worse than stock Ruby). What I'm considering is to seriously rework windows-pr such that I explicitly define the ANSI and Wide versions of every function, then do something like this in the source: def GetFileAttributes(file) if $KCODE == 'UTF8' GetFileAttributesW.call(file) else GetFileAttributesA.call(file) end end By using the -Ku option (or just setting $KCODE directly) you would get the wide version. Otherwise, you get the ANSI version. This seemed to work pretty well in the few tests that I've done. The most difficult part for authors using these functions would be to remember to convert strings to wide character versions first, before passing them to the functions. I provided a couple helper methods for that - multi_to_wide and wide_to_multi, that handles the most typical cases. Regards, Dan