简体   繁体   English

GHC:显示unicode字符

[英]GHC: Display of unicode characters

Further to my first question on the management of the unicode characters in the production of .exe file, this is also a bug in GHC? 关于管理.exe文件生成中的unicode字符的第一个问题,这也是GHC中的一个错误?

> print "Frère"
"Fr\233re"

print x is equivalent to putStrLn (show x) , where show converts a type of the Show class to a string representation. print x相当于putStrLn (show x) ,其中showShow类的类型转换为字符串表示形式。

In your case, x already has the String type. 在您的情况下,x已经具有String类型。 One might think that the String implementation of show would simply return its argument unchanged, but actually it transforms it into an ASCII string literal token with the same syntax as used in Haskell source code. 有人可能认为show的String实现只会返回其参数不变,但实际上它会将其转换为ASCII字符串文字标记,其语法与Haskell源代码中使用的相同。 This is done by surrounding it with quotes and by escaping 'special' characters (basically whatever is not on your keyboard). 这是通过用引号括起来并通过转义'特殊'字符(基本上不在键盘上的任何字符)来完成的。

So, this is not a bug but rather the expected behavior of print . 所以,这不是一个错误,而是print的预期行为。 If you want to output your string directly, use putStrLn instead. 如果要直接输出字符串,请改用putStrLn

Try 尝试

> putStrLn "Frère"
Frère      

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

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