Marshalling Haskell String <-> UTF-8

Bayley, Alistair Alistair_Bayley at ldn.invesco.com
Wed Sep 1 05:16:23 EDT 2004


I want to call a foreign C function that takes a UTF-8 encoded string as one
of its arguments (and there's also a version of the function that receives
UTF-16). Can someone point me to documentation or examples of how this would
be done? AFAICT (reading the FFI spec) marshalling a String to a CString is
locale-dependent, whereas I know that I want UTF-8/16.

Also, if a C function returns a UTF-8 (or UTF-16) encoded string, how do I
marshall this reliably into a Haskell String?

Can I use the UTF-16 functions directly with CWStrings? (I'm not sure
exactly what wchar_t is, as it's apparently dependent on the locale at
compile-time, and could be 8, 16, or 32 bits).

Thanks,
Alistair.

-----------------------------------------
*****************************************************************
Confidentiality Note: The information contained in this 
message, and any attachments, may contain confidential 
and/or privileged material. It is intended solely for the 
person(s) or entity to which it is addressed. Any review, 
retransmission, dissemination, or taking of any action in 
reliance upon this information by persons or entities other 
than the intended recipient(s) is prohibited. If you received
this in error, please contact the sender and delete the 
material from any computer.
*****************************************************************



More information about the Glasgow-haskell-users mailing list