haskell/win32 — pull request #7 by shelarcy (2012-10-03 20:53:45+00:00)
Title: Support multibyte error message

I/O Error message is garbled when using multibyte environment.

Prelude System.Directory> removeFile "doesn'tExist.txt"
*** Exception: DeleteFile "doesn'tExist.txt": does not exist (啅契ﾕ｡､・掬K樫[)
Prelude System.Directory>

Because localeEncoding doesn't support multibyte encodeing on Windows (except UTF-*).

* http://hackage.haskell.org/trac/ghc/ticket/3977

I think a few package reimplemt fail* function by this reason.

* http://www.patch-tag.com/r/gbacon/hs-kernel32/home
* http://hackage.haskell.org/package/winerror

I don't know how to implement TextEncoding by using MultiByteToWideChar and WideCharToMultiByte. So, I made temporary fix to show correct error message by MultiByteToWideChar and System.Win32.Console. After this chanage, I/O Error message is readable (in Japanese).

Prelude System.Directory> removeFile "doesn'tExist.txt"
*** Exception: DeleteFile "doesn'tExist.txt": does not exist (指定されたファイルが見つかりません。)

But ... above change causes mutually recursive moudle. Becuase fail* error functions are defined in System.Win32.Types, and System.Win32.Console imports System.Win32.Types.

I don't know which is better solution that 1. using hs-boot file, or 2. splitting fail* error functions to own System.Win32.Error module. So, I made two version of patch.

I like 2. way. So, this pull request comes from 2. way's version. I also made change 1. way in fix-error-recursive branch ( 21335a30161c099da79ae9619c9782e5e32e4644...9960f7d9688e70f03824b7b9ff8461fee9ffb2bb ).