作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我使用 windows 10 和 powershell,Haskell 似乎对标准输入的 UTF 编码有一些问题:
> chcp 65001
> stack ghci
...
> putStrLn "자"
자
> x <- getLine
자
> x
"\EOT"
> interact id
자
╝
最佳答案
我怀疑 GHC 在 latin1 编码(或类似编码)上运行,而 putStrLn "자"
只是偶然工作。您可以按如下方式检查:
> import System.IO
System.IO> hGetEncoding stdin
如果它以 UTF-8
回复,我的假设是错误的。但是,如果它使用 UTF-8
以外的内容进行回复,您可以使用 hSetEncoding
显式声明控制台期望的编码:
System.IO> hSetEncoding stdin utf8
您可能还想为 stdout
和 stderr
执行此操作。参见 the documentation了解更多详情。
关于windows - haskell ,WinX : UTF8 stdin causes problems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45965471/
我使用 windows 10 和 powershell,Haskell 似乎对标准输入的 UTF 编码有一些问题: > chcp 65001 > stack ghci ... > putStrLn "
我是一名优秀的程序员,十分优秀!