[Haskell-beginners] hGetContents

David Virebayre dav.vire+haskell at gmail.com
Mon Aug 23 04:32:46 EDT 2010


2010/8/23 Luca Ciciriello <luca_ciciriello at hotmail.com>:
> I all.

> I'm reading a txt file using the code

> inh <- openFile "myfile.txt" ReadMode
> contents <- hGetContents inh

> On Windows all works fine. I'm able to read the file without any problems.
> On Mac OS X (10.6.4), with the same txt file and the same code above, I get
> the exception:

> hGetContents: invalid argument (Illegal byte sequence).

> In both the systems (Mac and Windows) I've installed the same Haskell
> platform 2010.2.0.0 (GHC 6.12.3).

> Any idea why I've this behaviour on Mac system?

> Thanks in advance for any answer.

Perhaps a missmatch between the file's encoding (utf8, iso-8859-1,
etc) and your system's locale settings.

David.


More information about the Beginners mailing list