[Haskell-beginners] hGetContents exception

Luca Ciciriello luca_ciciriello at hotmail.com
Wed Sep 14 14:50:12 CEST 2011


Hi All.
I'm using the function hGetContents in order to read some text file. If one or more of these text file have a wrong UTF encoding, I get the error:

hGetContents: invalid argument (Illegal byte sequence)

My workaround is to open the wrong encoded file in emacs and create a copy of this file (cut and paste in a new buffer). After this operation the new file has a correct UTF encoding and hGetContents doesn't complain any more.

Is there a better way to read (without complaining) such wrong file without an external action (emacs)?

Thanks in advance for any answer.

Luca.

 


More information about the Beginners mailing list