[Haskell-cafe] question about GHC and Unicode

John Goerzen jgoerzen at complete.org
Mon Apr 28 09:14:26 EDT 2008


On Sun April 27 2008 2:02:25 pm Don Stewart wrote:
> zefria:
> >    In GHC there's a GHC.Unicode library, but for a string such as "
> > *AIOO", a GHC compiled program prints it as a string of unknown
> > characters, and in the interpreter, the string evaluates to a string of
> > escape sequences instead of displaying properly.
> >
> >    Is there a way to get/activate unicode support in GHC?
>
> GHC supports unicode internally, and String and Char are all unicode.
>
> To do unicode IO however, you need to use the utf8-string package:
>
>     http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string
>
> Just import and use IO functions from System.IO.UTF8, and that's it!

That's a wonderful interface, but unfortunately it appears to assume that 
your Unicode I/O is always UTF-8, and never UTF-16.  I happen to deal with 
more UTF-16 data than UTF-8 over here at the moment.

(Did I mention UTF-7 or UTF-EBCDIC?  horrors...)

There is a Haskell binding for iconv for those that need UTF-16, but it 
doesn't appear to have as convenient an interface.

-- John


More information about the Haskell-Cafe mailing list