For me, the Chinese characters printing is not smooth. Like the putStrLn
cases:
*Main> putStrLn "中文"
-
*Main> putStrLn "中文!"
-?
I then follow a suggestion from stackoverflow to use "MyPrint.hs"
to print Chinese characters in output without seeing the character shown. The loaded original MyPrint
is as following:
module MyPrint (myPrint, myShow) where
-- preparing for the 7.6.1
myPrint :: Show a => a -> IO ()
myPrint = putStrLn . myShow
myShow :: Show a => a -> String
myShow x = con (show x) where
con :: String -> String
con [] = []
con li@(x:xs) | x == '\"' = '\"':str++"\""++(con rest)
| x == '\'' = '\'':char:'\'':(con rest')
| otherwise = x:con xs where
(str,rest):_ = reads li
(char,rest'):_ = reads li
In winGHCi, the result is like this:
*MyPrint> myPrint "asf萨芬速读法"
"asf(?"
Neither Chinese characters be shown in GHCi. Why and how to overcome it? Thanks!