[Haskell-cafe] How to use Unicode strings?

Don Stewart dons at galois.com
Sat Nov 22 13:02:35 EST 2008


alexey.skladnoy:
> >
> > That really ought to work.  Is the file encoded in UTF-8 (rather than,
> > eg. latin-1)?
> >
> This should pretend to work. Simple print functions garble unicode characters.
> For example :
> 
> > putStrLn "Ну и где этот ваш хвалёный уникод?"
> 
> prints following output
> 
> C 8 345 MB>B 20H E20;Q=K9 C=8:>4?
> 
> Not pretty? Althrough Dmitri's variant seems to work fine.

Use the UTF8 printing functions,

    import qualified System.IO.UTF8 as U

    main = U.putStrLn "Ну и где этот ваш хвалёный уникод?"

Running this,

    *Main> main
    Ну и где этот ваш хвалёный уникод?

-- Don


More information about the Haskell-Cafe mailing list