[Haskell-cafe] The Nature of Char and String

John Meacham john at repetae.net
Mon Jan 31 11:03:34 EST 2005


On Sun, Jan 30, 2005 at 07:58:50PM -0600, John Goerzen wrote:
> On Sun, Jan 30, 2005 at 07:39:59PM +0000, Ben Rudiak-Gould 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.

The ghc standard libraries only work with latin1, however, there are
quite a few libraries out there for reading/writing text in the current
locale (or a set format like UTF-8) so ghcs limitations are not too bad
in practice if you need unicode. Some are even drop-in replacements for
the standard prelude IO functions.

It should also be said that these are limitations of the current haskell
tools and not the language itself, the language specifies unicode and
leaves the details of IO up to implementations. 
        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell-Cafe mailing list