I have the following code that works fine if the file does not have utf-8 characters:
module Main where import Ref main = do text <- getLine theInput <- readFile text writeFile ("a"++text) (unlist . proc . lines $ theInput)
With utf-8 characters, I get the following: hGetContents: invalid argument (invalid byte sequence)
Since the file I'm working with has utf-8 characters, I would like to handle this exception so that, if possible, reuse the functions imported from Ref .
Is there a way to read the utf-8 file as an IO String so that I can reuse my Ref functions? What changes should I make to my code ?. Thanks at Advance.
I am attaching function declarations from my Ref module:
unlist :: [String] -> String proc :: [String] -> [String]
from the prelude:
lines :: String -> [String]
haskell utf-8
George peppa
source share