Ticket #3300 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

System.IO and System.Directory functions not Unicode-aware under Windows

Reported by: shu Owned by: simonmar
Priority: normal Milestone: 6.12.1
Component: libraries/directory Version: 6.11
Keywords: unicode Cc: YitzGale
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Under Windows, System.Directory.getDirectoryContents seems to apply encoding conversions on filenames at the syscall level.

I have several files with Japanese names, but my default program locale is English. Unicode-aware applications (that is, most modern Windows programs) have no problems with this. Calling getDirectoryContents on a folder with Japanese names, however, returns strings consisted of question marks "???".

If I switch the default program locale to, say, Japanese, then the files are returned in ShiftJIS, but I lose information such as accented Latin characters.

Change History

Changed 4 years ago by YitzGale

  • cc YitzGale added
  • keywords unicode added
  • version changed from 6.10.3 to 6.11
  • os changed from Unknown/Multiple to Windows
  • summary changed from System.Directory.getDirectoryContents not unicode-aware under Windows to System.IO and System.Directory functions not Unicode-aware under Windows

This is a more general problem - summary changed to reflect that.

See detailed discussion in this thread:  http://www.haskell.org/pipermail/haskell-cafe/2009-June/062795.html

Besides getDirectoryContents, at least the following functions also need to be fixed, because they are ACP-only:

openFile c_stat c_chmod c_SearchPath c_SHGetFolderPath

Changed 4 years ago by YitzGale

This change needs to be coordinated with #3308 ("getArgs should return Unicode on Windows") so that it will still work to read a file path from the command line and use it to access files.

See also #3307 ("System.IO and System.Directory functions not Unicode-aware under Unix").

Changed 4 years ago by simonmar

  • owner set to simonmar
  • difficulty set to Unknown
  • milestone set to 6.12.1

Changed 4 years ago by simonmar

I have done openFile, getDirectoryContents, and everything that uses c_stat.

libraries/base:

Thu Jun 18 06:54:58 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * Windows: Unicode openFile and stat functions

libraries/Win32:

Thu Jun 18 03:19:31 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * add findFirstFile, findNextFile, findClose

libraries/directory:

Thu Jun 18 06:48:58 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * Windows: Unicode getDirectoryContents and setPermissions

Changed 4 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

These changes are now complete.

libraries/Win32:

Mon Jun 29 03:47:50 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * add SHGetFolderPath support

libraries/directory:

Mon Jun 29 04:26:04 PDT 2009  Simon Marlow <marlowsd@gmail.com>
  * move Win32 SearchPath and SHGetFolderPath into the Win32 package
Note: See TracTickets for help on using tickets.