[Haskell-cafe] Unicode workaround for getDirectoryContents under
shu at rfrn.org
Sat Jun 13 23:41:46 EDT 2009
It seems like getDirectoryContents applies codepage conversion based
on the default program locale under Windows. What this means is that
if my default codepage is some kind of Latin, Asian glyphs get
returned as '?' in the filename. By '?' I don't mean that the font is
lacking the glyph and rendering it as '?', but I mean 'show (head
(getDirectoryContents "C:\\Music"))' returns something that looks like
like "?? ????".
This is a problem as I can't get the filenames of my music directory,
some of which are in Japanese and Chinese, some of which have accents.
If I change the default codepage to Japanese, say, then I get the
Japanese filenames in Shift-JIS and I lose all the accented letters.
I have filed this as a bug already, but is there a workaround in the
meantime (I don't know the Win32 API, but didn't see anything that
looked like it would help under System.Win32 anyways) that lets me
gets the list of files in a directory that's encoded in some kind of
More information about the Haskell-Cafe