GHC 6.12.1からUnicode IOがサポートされたらしい

Unicode Text I/Oというのが入ったらしい。
http://www.sampou.org/cgi-bin/w3ml.cgi/haskell-jp/msg/480


以下、Windowsで試しました。
stdoutにはうまく出力できないのでファイルに出力。


main.hs(UTF-8で保存)

import System.IO

main = do
  h <- openFile filename WriteMode
  hSetEncoding h utf8
  hPutStrLn h "あいうえお"
  hClose h

filename = "a.txt"


a.txt

あいうえお

おぉ、ちゃんと出力された。


でもhPrintだとこうなった。

"\12354\12356\12358\12360\12362"

うーん、Windowsの方は今後に期待かな。


追記:
hPrintでうまくいかないのはshowのせいかも