utf 8 - Read file with UTF-8 in Haskell as IO String -
i have following code works fine unless file has utf-8 characteres : module main import ref main = text <- getline theinput <- readfile text writefile ("a"++text) (unlist . proc . lines $ theinput) with utf-8 characteres this: hgetcontents: invalid argument (invalid byte sequence) since file i'm working has utf-8 characters, handle exception in order reuse functions imported ref if possible. is there way read utf-8 file io string can reuse ref 's functions?. modifications should make code?. in advance. i attach functions declarations ref module: unlist :: [string] -> string proc :: [string] -> [string] from prelude: lines :: string -> [string] this can done ghc's basic (but extended standard) system.io module, although you'll have use more functions: module main import ref import system.io main = text <- getline inputhandle <- openfile text readmode hsetencoding inputhandle u...