Reputation: 1498
I use windows 10 and powershell, it seems that Haskell have some issues with UTF encoding from stdin:
> chcp 65001
> stack ghci
...
> putStrLn "자"
자
> x <- getLine
자
> x
"\EOT"
> interact id
자
╝
Upvotes: 2
Views: 154
Reputation: 153352
I suspect GHC is operating on a latin1 encoding (or similar), and putStrLn "자"
only worked by accident. You can check this as follows:
> import System.IO
System.IO> hGetEncoding stdin
If this replies with UTF-8
my hypothesis is wrong. But if it replies with something other than UTF-8
, you can explicitly declare which encoding the console is expecting with hSetEncoding
:
System.IO> hSetEncoding stdin utf8
You may also want to do this for stdout
and stderr
. See the documentation for more details.
Upvotes: 1