
Hi, is there a library which converts from utf-16 to utf-8? Günther

iconv? Günther Schmidt wrote:
Hi,
is there a library which converts from utf-16 to utf-8?
Günther
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Günther Schmidt
is there a library which converts from utf-16 to utf-8?
The text library can (you can also choose between big and little endian UTF-16).
Günther
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Hi Ivan, 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. Günther BTW: I need this function because I'm using HDBC-ODBC with MS Access and in MS Access apparently every string is in UTF-16. Am 28.01.10 12:47, schrieb Ivan Lazar Miljenovic:
Günther Schmidt
writes: is there a library which converts from utf-16 to utf-8?
The text library can (you can also choose between big and little endian UTF-16).
Günther
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Gunther, Thursday, January 28, 2010, 4:07:07 PM, you wrote:
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.
Haskell String type isn't UTF-8 encoded. it's [Char] where Char is in UCS-4 aka UTF-32 :)
BTW: I need this function because I'm using HDBC-ODBC with MS Access and in MS Access apparently every string is in UTF-16.
look at withTString and its friends: http://hamaoka.org/ghc6/libraries/Win32/src/System-Win32-Types.html
Am 28.01.10 12:47, schrieb Ivan Lazar Miljenovic:
Gunther Schmidt
writes: is there a library which converts from utf-16 to utf-8?
The text library can (you can also choose between big and little endian UTF-16).
Gunther
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

2010/1/28 Bulat Ziganshin
Hello Gunther,
Thursday, January 28, 2010, 4:07:07 PM, you wrote:
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.
Haskell String type isn't UTF-8 encoded. it's [Char] where Char is in UCS-4 aka UTF-32 :)
That's not quite correct. [Char] is a sequence of Unicode code points, UTF-32 is one possible encoding of those code points. The difference is similar to the one between an integer an e.g. its string representation. Cheers, Johan

Hello Johan, Thursday, January 28, 2010, 4:20:48 PM, you wrote:
Haskell String type isn't UTF-8 encoded. it's [Char] where Char is in UCS-4 aka UTF-32 :)
That's not quite correct. [Char] is a sequence of Unicode code points, UTF-32 is one possible encoding of those code points. The difference is similar to the one between an integer an e.g. its string representation.
i say exactly about its encoding :D -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Günther Schmidt
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 efficient). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com
participants (5)
-
Bulat Ziganshin
-
Günther Schmidt
-
Ivan Lazar Miljenovic
-
Johan Tibell
-
Miguel Mitrofanov