我发现snap将utf-8编码的文本显示为不可读的字符,代码和结果如:
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
...
site :: Snap ()
site =
ifTop (writeText $ T.pack "hello world! 你好") <|> -- Here is the utf-8 text
route [ ("foo", writeBS "bar")
, ("query/:pat", echoHandler)
] <|>
dir "static" (serveDirectory ".")
浏览器中的输出是:
hello world! ä½ å¥½
我搜索stackoverflow并发现有一个类似的问题(How to show utf8 text with snap and heist?),但它似乎不起作用。我该如何处理这个utf-8问题?