[Haskell-cafe] UTF-16 to UTF-8

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Jan 28 08:17:05 EST 2010

Günther Schmidt <gue.schmidt at web.de> writes:
> thanks for the tip, but how do I use the library?
> I can't really make out how to feed it UTF-16 and get String (UTF-8)
> back.

One way (probably not very efficient):

import Data.Text.Encoding

convert :: Bytestring -> Bytestring
convert = encodeUtf8 . decodeUtf16LE

No claims are made about efficiency of this technique (mainly because
unless you're already using Bytestrings, then it probably isn't very

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list