This is exactly what happens:
(btw, the same thing happens in Python, so the trouble must be in the Oracle 
odbc driver. But this is also what happens today to any Haskell business 
application which connects to Oracle, as - to my knowledge - there is no native 
Oracle driver for Haskell)

...
stmt0 <- query c $ "select 'Ã' as TEST from dual"
stmt1 <- query c $ "select '" ++ chr(195):chr(131):[] ++ "' as TEST from dual"
stmt2a<- query c $ "select '" ++ [chr(195*256 + 131)] ++ "' as TEST from dual"
stmt2b<- query c $ "select '" ++ [chr(131)] ++ "' as TEST from dual"
stmt3 <- query c $ "select chr(195*256 + 131) as TEST from dual"
...

after execution on a UTF-8 Oracle9i instance:
0:  "TEST", "\195\131"
1:  "TEST", "\195\131\198\146"
2a: "TEST", "\198\146"
2b: "TEST", "\198\146"
3:  "TEST", "\195\131"

0 is the reference: UTF-8 encoding of an A with a tilde on the top.
1 is UTF-8 encoding (by Oracle) of an already encoded UTF-8 string
2a and 2b show that the high byte is stripped: \198\146 is the UTF-8 encoding 
of chr(131)
3 is the only (almost useless) workaround I've found.

Of course, with 3 byte chars things get even more confused.

Enrico



-----Messaggio originale-----
Da: Krasimir Angelov [mailto:[EMAIL PROTECTED]
Inviato: giovedì 27 gennaio 2005 15.41
A: glasgow-haskell-users@haskell.org
Oggetto: Re: Problem with DB and Char size (2)


On Thu, 27 Jan 2005 06:34:40 -0800, John Meacham <[EMAIL PROTECTED]> wrote:
> On Thu, Jan 27, 2005 at 04:23:52PM +0200, Krasimir Angelov wrote:
> > HSQL uses withCString internally. withCString strips the higher order
> > bytes from Char.
> 
> You should be able to replace withCString with withUTF8String from my
> CWStringBasic module, which you can get from here:
> http://repetae.net/john/recent/src/HsLocale/CWStringBasic.hs
> 
> and is part of my bigger HsLocale project  
> http://repetae.net/john/recent/out/HsLocale.html
> but just that one file should be enough if all you need is UTF8.
>        John

Santoemma Enrico said that Oracle ODBC driver expects UCS-2 instead of
UTF-8 so this will not help.

Krasimir
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to