I'm trying to convert my database code to the SQL library of MBS because the
Real Studio ODBC driver has too many bugs, but I'm experiencing troubles with
encoding.
Here are the facts:
Connecting to Informix server using the native IBM driver from Mac.
The database is encoded with en_US.819 which is the same as ISO-8859-1 or
ISOLatin1 and contains some german words with umlauts, etc.
Trying to write a field with (for example) the word "weiß" I can't handle to
write it in the correct encoding.
Here it's the relevant code:
cmd.setCommandText("INSERT INTO test_tbl VALUES(:1)")
dim encodedString as String = ConvertEncoding("weiß", Encodings.ISOLatin1)
dim sqlStr as new SQLStringMBS(encodedString)
cmd.Param(1).setAsString(sqlStr)
cmd.Execute
as a result the string is written encoded in UTF8
Examining the binary data of the encodedString variable I get:
hex 77 65 69 df
text w e i ß
which is correct for the ISOLatin1 char table
while examining the binary data written on database (as well the string
returned from SQLStringMBS.CopyBytes) I get:
hex 77 65 69 c3 9f
text w e i ß
which is UTF8
tried an alternative method for writing, avoiding the SQLStringMBS:
dim encodedString as String = ConvertEncoding("weiß", Encodings.ISOLatin1)
cmd.setCommandText(ConvertEncoding("INSERT INTO test_tbl
VALUES("+encodedStr+")", Encodings.ISOLatin1))
cmd.Execute
but I got the same results.
Additionally, I have similar troubles reading values. Trying to fetch a field
containing an ISOLatin1 encoded string, I only get the string truncated at
first char which is not plain ASCII. So reading "weiß" I get "wei". Again, no
problem If the string is UTF8 encoded.
I tought to the Informix driver at first, but this sound strange since the
en_US.819 encoding is the default one for Informix.
Thanks for help.
Massimo Valle
SACO Software and Consulting GmbH, Mühlgasse 5, D-97840 Hafenlohr
Tel.: ++49 9391 90890-0, Fax: ++49 9391 90890-99, E-Mail: [email protected]
Amtsgericht Würzburg HRB 5410, Geschäftsführer: Peter Schubert,
Dipl.-Wirt.ing.(FH) Thorsten Beck
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info