MySQL Forums
Forum List  »  Connector/ODBC

Re: Data Source Name in UTF-8
Posted by: Bogdan Degtyariov
Date: April 23, 2017 11:04PM

Hello Yi Chang,

There are a few things that might cause the problem to appear.
The ODBC standard defines two ways of string/text data representation:

1. single-byte characters. ODBC API functions that use such characters have "A" suffix, which stands for ANSI. For instance: SQLDriverConnectA(). This function family treat the \0 byte as a string terminator.

2. multi-byte wide characters. ODBC API functions that use such characters have "W" suffix, which stands for for Wide. It can also be called Unicode. However, it is important to understand that the Driver Manager (such as UnixODBC) does not treat all Unicode character sets equally. In most cases wide characters are defined as 16-bit entities. This means that the W family of functions might not accept 32-bit characters such as UTF-32. This is only true for the functions parameters of SQLWCHAR type.

The UTF-8 character set has characteristics of both representations because the UTF-8 strings are terminated by \0 byte, which allows the possibility of using ANSI versions.
On the other hand UTF-8 has multi-byte characters of variable length. This is a crucial moment because SQLWCHAR has a fixed length defined at the compilation time, which cannot be changed later. In other words, UTF-8 data from your DSN has to be converted to fixed-length wide characters (usually UTF-16 or UCS-2). This conversion is done by the driver manager.

There is an option IconvEncoding inside odbcinst.ini file (the one where you register the driver, not DSN). This option is not documented well, but it certainly affects the conversion for the driver parameters.
Try setting IconvEncoding = 1 or IconvEncoding = 0 or removing it from odbcinst.ini at all.

Please let me know if it helped.
Thanks.

Options: ReplyQuote


Subject
Written By
Posted
April 19, 2017 05:39PM
Re: Data Source Name in UTF-8
April 23, 2017 11:04PM
April 25, 2017 10:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.