[Haskell-cafe] How does GHC read UNICODE.

Don Stewart dons at galois.com
Mon May 19 22:43:48 EDT 2008


leaveye.guo:
> Hi Haskellers:
> 
>     I am a Chinese.
> 
>     Mostly, it is needed to read/write UNICODE charactors.
> 
>     Currently, I can only use the ByteString module in GHC 6, 2007.
>     But I feel it is not an easy method.
> 
>     Does GHC support it now ? or, is there any other way to do this ?
> 
>     Regards

Hello!

Chars in Haskell are 32 bit wide values, so they can happily accept
various unicode encodings. The main issue then is doing IO with Chars.

You can use either bytestrings, which will ignore any encoding, or 
the utf8-string package for Strings, which will properly encode and
decode utf8 values to Char.

    http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string

-- Don


More information about the Haskell-Cafe mailing list