[Haskell-beginners] Simple UTF-8 output

Christian Maeder Christian.Maeder at dfki.de
Fri May 27 11:51:38 CEST 2011


Am 27.05.2011 06:54, schrieb Christopher Howard:
> Hi. I'm trying to print out UTF-8 strings (pulled from a MySQL database
> through HDBC.ODBC). If I just print them out, the extended characters
> are printed out as question marks.

In this case the character encoding of your display device (terminal) is 
still wrong.

ghci
Prelude> putStrLn "\228"
ä

should work.

Christian

> If I use show on them (which is what
> I want to do in this case) they are printed as \NNNNN... (presumably the
> Unicode number).
>
> Google brought up hundreds of topics for "Haskell utf-8" but its like
> looking for a single tree in a forest.
>
> I took great care to ensure my Gentoo Linux system is UTF-8 ready, and I
> can type or echo utf-8 characters on the command line just fine.
>
> # locale
> LANG=en_US.UTF-8
> LC_CTYPE="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER="en_US.UTF-8"
> LC_NAME="en_US.UTF-8"
> LC_ADDRESS="en_US.UTF-8"
> LC_TELEPHONE="en_US.UTF-8"
> LC_MEASUREMENT="en_US.UTF-8"
> LC_IDENTIFICATION="en_US.UTF-8"
> LC_ALL=
>



More information about the Beginners mailing list