
21 Mar
2012
21 Mar
'12
8:09 a.m.
On Wed, Mar 21, 2012 at 3:35 AM, Yves Parès
Hello,
I have to interact with a C++ library that accepts as string types (putting c++ strings aside) pointers of wchar_t (CWString in Haskell) or unsigned 32-bit int (Ptr Word32 for UTF-32 codepoints).
I have read what text, bytestring and base provide, but Text can only be directly converted to (Ptr Word16), and if I use encodeUTF32 to get a ByteString, then I only get useAsCString, no direct conversion to CWString or Ptr WordXX is possible.
A CString is a (Ptr CChar). You can then use castPtr to get whichever pointer type you need, if you believe the underlying buffer has the representation you want (in this case, UTF-32). It still won't be null-terminated, however. Antoine