简体   繁体   English

IO操作中如何处理非ASCII字符?

[英]How do I deal with non-ASCII characters in IO operations?

As the title says, I'm having a problem dealing with characters outside of ASCII (like 'á','ã', etc) in IO operations.正如标题所说,我在 IO 操作中处理 ASCII 之外的字符(如“á”、“ã”等)时遇到问题。 Look at the example (Unix environment):看例子(Unix环境):

import System.Cmd
system "ls aaaá"

Which returns the ls command code error:它返回 ls 命令代码错误:

(...)ls: can't access "aaa�" : no such file or directory(...)

How can I fix this?我怎样才能解决这个问题?

根据hammar的评论,我安装了GHC v7.2.2(我的旧版本是v6.9.9),并且修复了错误。

  1. Check your system locale检查您的系统区域设置
  2. Check the encoding of your Haskell sources检查您的 Haskell 源代码的编码

If both are UTF8 it should work.如果两者都是UTF8,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM