shokosブログ

プログラミング

windowsでHaskellのIOまわりで日本語を文字化けなく表示させる方法

ghc7.0.2

utf8-stringをインストール。
こちら参照
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string

cabal install utf8-string


System.IO.UTF8のモジュールを見ると、だいたいIO周りが揃っている!

appendFile      hGetLine        openBinaryFile  readFile
getContents     hPStr         print           readLn
getLine         hPStrLn       pStr          withBinary
hGetContents    interact        pStrLn        writeFile


試しに

Prelude> import System.IO.UTF8 as S
Prelude System.IO.UTF8> S.writeFile "test.txt" "にゃん"

うまくいった!