Bug #62728 | ODBC Connector 5.1 utf8 stored incorrectly | ||
---|---|---|---|
Submitted: | 13 Oct 2011 22:59 | Modified: | 23 Apr 2024 10:07 |
Reporter: | Alon S | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | Connector / ODBC | Severity: | S2 (Serious) |
Version: | 5.1.8 | OS: | Windows |
Assigned to: | Bogdan Degtyariov | CPU Architecture: | Any |
Tags: | ASP, odbc 5.1, utf8 |
[13 Oct 2011 22:59]
Alon S
[13 Oct 2011 23:02]
Alon S
connection definitions: cn1 ---- Set cn1 = CreateObject ("ADODB.Connection") cn1.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Port=3306;Option=3;Server=xxxxxx;User ID=xxxxx;Password=xxxxx;Database=xxxxx;" cn1.open connection definitions: cn2 ---- Set cn2 = CreateObject ("ADODB.Connection") cn2.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Port=3306;Option=3;Server=xxxxxx;User ID=xxxxx;Password=xxxxx;Database=xxxxx;charset=utf8" cn2.open
[17 Oct 2011 10:34]
Lawrenty Novitsky
As for the question "why doesn't option #4 work". Since 5.1 is a unicode driver MS driver translate all non-unicode calls(SQLExecDirect) to its unicode counterpart(SQLExecDirectW) call. Doing that it converts input string parameters to SQLWCHAR. It assumes that string data is encoded in ANSI charset of the system it is being executed on. And that is unlikely to be UTF8. Thus driver receives wrong utf16 strings and thus wrong data goes to a database.
[18 Oct 2011 11:38]
Alon S
understood. so my only option to work with utf8 and asp without opening a recordset object for nothing is to decode the utf8 to ansi before sending it to the execute method?
[18 Oct 2011 17:44]
Lawrenty Novitsky
Yes, that should work.
[19 Oct 2011 11:20]
Bogdan Degtyariov
Alon, Can you attach a short ASP test case with some utf-8 data you intended to insert? We have to make sure there is no double string conversion. This happens when each UTF-8 byte is interpreted as wide character (assuming UTF-16) and then converted back to UTF-8. Thanks.
[22 Oct 2011 15:59]
Alon S
test case for hebrew text insertion with utf8 encoding
Attachment: test.asp (text/plain), 900 bytes.
[22 Oct 2011 16:03]
Alon S
I have added a test file. thank you
[22 Oct 2011 16:04]
Alon S
* you will have to change the connection string info to your db
[7 Nov 2011 10:51]
Bogdan Degtyariov
Thanks for uploading the test case. Verified with Connector/ODBC 5.1.9
[20 Dec 2022 5:44]
Bogdan Degtyariov
Posted by developer: This is to be rechecked against MySQL Connector/ODBC 8.0
[23 Apr 2024 5:10]
Bogdan Degtyariov
Posted by developer: Re-checked against the MySQL ODBC driver 8.4.0. Both ANSI and Unicode versions worked correctly. The ANSI version requires data strings in UTF8. The UNICODE version requires data strings in UTF16 (SQLWCHAR), which will be converted by the driver to UTF8. Closing the ticket.
[23 Apr 2024 10:07]
Alon S
I wonder if I could also wait 13 years with a bug and then tell my boss that I can't repro.. But good to know you're still alive mate! Let's meet here in 2037!