[Haskell-cafe] Re: HDBC, character encoding
John Goerzen
jgoerzen at complete.org
Fri Apr 4 10:27:35 EDT 2008
On 2008-04-04, Peter Gammie <peteg42 at gmail.com> wrote:
>> through, however it is obtained, and let the programmer set the
>> encoding as desired. If this approach isn't working for people, I'd
>> like to fix it, but want to make sure it's done right.
>
> Assuming you're talking about the FFI's mandated behaviour, I'm not
> very comfortable with the encoding depending on the C locale, for two
> main reasons:
>
> - the program I'm hacking runs on some web host's server that is an
> unknown quantity.
> - GHC has a few quirks in how it implements the FFI, better to avoid
> the part that interprets characters.
>
> If you want to be general, I guess you could abandon String (at the
> HDBC level) and use [Word8]/ByteString everywhere, then provide some
> convenience wrappers. Then you can uniformly handle binary and textual
> data. I am not familiar with your project though.
I've looked at the Data.ByteString.Internal API, and it looks like
that ought to work. Oddly, the Data.ByteString.Lazy.Internal API does
not seem to export enough to work with it in FFI.
I can see this being a performance and ease-of-use win in some
situations. I don't think it's an actual feature difference, though.
If you can represent it as a [Word8], you can represent it as a
[Char], and it will be converted to the same underlying data for the
trip through FFI.
-- John
More information about the Haskell-Cafe
mailing list