[Haskell-cafe] The Nature of Char and String

Glynn Clements glynn at gclements.plus.com
Wed Feb 2 07:57:30 EST 2005

John Goerzen wrote:

> > > * If I use hPutStr on a string, is it guaranteed that the number of
> > >   8-bit bytes written equals (length stringWritten)?
> > 
> > Yes, if the handle is opened in binary mode. No if not.
> Thank you for the informative response.
> If a file is opened in text mode, what encoding does Haskell grok on
> input?  And what encoding does it generate on output?  I'm assuming
> it's UTF-8 on output, but I don't know for sure.

Haskell doesn't specify an encoding. GHC and Hugs both assume

The only difference between binary and text modes is that text mode
converts between the platform's EOL conventions (i.e. LF on Unix, CRLF
on Windows) and LF.

Glynn Clements <glynn at gclements.plus.com>

More information about the Haskell-Cafe mailing list