
28 Nov
2010
28 Nov
'10
6:53 a.m.
Michael Snoyman wrote:
Perhaps a silly question, but are you certain that the input file is valid UTF-8?
That is a very good point.
You could also try using the readFile from utf8-string... [or] read the contents as a lazy bytestring and then use the decode functions...
Those approaches are now both deprecated. Either do what you are doing, which gives you conceptually simple strings as lists of Char. Or, for better efficiency, use the text package:
import qualified Data.Text.Lazy as T main :: IO () main = do text <- T.readFile "unicode.txt" T.putStr text
In any case, you still need to have the correct encoding set on the handles as before. (And the input needs to be valid for your selected encoding.) Regards, Yitz