Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Simple UTF-8 output (Erik de Castro Lopo)
   2. Re:  Simple UTF-8 output (Christian Maeder)


----------------------------------------------------------------------

Message: 1
Date: Fri, 27 May 2011 17:38:07 +1000
From: Erik de Castro Lopo <[email protected]>
Subject: Re: [Haskell-beginners] Simple UTF-8 output
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Elvio Toccalino wrote:

> I usually pull such values as ByteStrings. The utf8-strings package
> provides printing functions for such data.
> Also, if you'd like to work on it as Text, there's the
> Data.Text.Encodings module, to decodeUTF8 or decodeASCII ByteString's
> into Text.

I would recommend Data.Text because that is designed for Text
encodings while ByteString is designed for handling arrays
of bytes (eg things like data read from an network socket).

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



------------------------------

Message: 2
Date: Fri, 27 May 2011 11:51:38 +0200
From: Christian Maeder <[email protected]>
Subject: Re: [Haskell-beginners] Simple UTF-8 output
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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=
>



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 35, Issue 54
*****************************************

Reply via email to