
On 03/04/2008, at 9:10 PM, John Goerzen wrote:
On 2008-04-01, Peter Gammie
wrote: I added some stuff to HSQL (not HDBC) and HaskellDB so that UTF8 can be used to talk to the database. It's not very pretty though, so I haven't tried to get it merged.
Do you have a diff somewhere? I'd be interested in your approach, to see if the same thing would make sense in HDBC.
My approach is simple: when creating a connection to the database, ask for two functions (a codec pair) and stash them with the rest of the DB state. The types involved are [Word8] and String. I started out trying to use ByteString instead of [Word8] but it didn't bring much to the table in my case.
I had generally been of the opinion that HDBC should just pass data 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. cheers peter