Read file with UTF-8 in Haskell as IO String
问题 I have the following code which works fine unless the file has utf-8 characteres : module Main where import Ref main = do text <- getLine theInput <- readFile text writeFile ("a"++text) (unlist . proc . lines $ theInput) With utf-8 characteres I get this: hGetContents: invalid argument (invalid byte sequence) Since the file I'm working with has UTF-8 characters, I would like to handle this exception in order to reuse the functions imported from Ref if possible. Is there a way to read a UTF-8