[Haskell-cafe] The Nature of Char and String

Ketil Malde ketil+haskell at ii.uib.no
Wed Feb 2 08:05:46 EST 2005

Glynn Clements <glynn at gclements.plus.com> writes:

> The Haskell functions accept or return Strings but interface to OS
> functions which (at least on Unix) deal with arrays of bytes (char*),
> and the encoding issues are essentially ignored. If you pass strings
> containing anything other than ISO-8859-1, you lose.

I'm not sure it's as bad as all that. You lose the correct Unicode
code points (i.e. chars will have the wrong values, and strings may be
the wrong lenght), but I think you will be able to get the same bytes
out as you read in.  So in that sense, Char-based IO is somewhat
encoding neutral.

So one can have Unicode both in IO and internally, it's just that you
don't get both at the same time :-)

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list