[Haskell-cafe] how to use a literal string with bystring useAsCString

minh thu noteed at gmail.com
Mon Feb 9 12:13:23 EST 2009


I have a Haskell source file encoded in utf-8.
Inside that source, I have literal strings that I'd
like to pass to a C function.

withCString does the job well until I tried to use
the double-quote character ". I get
/usr/lib/ghc-6.10.1/ghc: `@: Bad font file format
(even when using (chr 34) instead).

I didn't understand the reason of this behavior (since
the double quote is just ascii) but
tried to use useAsCString but coudn't do it.
I can ByteString.Char8.pack my string but the problem
remains. I tried to use IConv but it uses UTF8.ByteString
and I don't know how to make the conversion so I can
use useAsCString or withCString.

Any idea ?

More information about the Haskell-Cafe mailing list