FirebirdSQL/firebird-odbc-driver

charset conversion error for sql (VAR)CHAR to SQL_C_WCHAR conversion [ODBC181]

firebird-automations opened this issue · 10 comments

Submitted by: Jojakim Stahl (jstahl)

Attachments:
bug-181.patch
FbOdbc.zip

Votes: 1

The charset conversion from db cp encoded string to SQL_C_WCHAR (wide char string) mixes up length Information etc.
It's based on the assumption 1 Byte in db cp = 2 Byte in wide notation. This relationship is not valid. For UTF8 1-4 bytes may result in 1 or 2 wide chars = 2 or 4 bytes.

Commits: 9fca7df d94a113

Commented by: Jojakim Stahl (jstahl)

uploaded patch

Modified by: Jojakim Stahl (jstahl)

Attachment: bug-181.patch [ 12613 ]

Commented by: Guy Dion (gdfbu)

I had the following problem:

SELECT LOWER('ÉÈËïÎÀÖÙÛÇ') FROM RDB$DATABASE

correctly returned 'çöùûàéèëïî' with JayBird JDBC driver but returned a truncated string 'çöùûà' using ODBC driver 2.0.3 or 2.0.4 (see issue ODBC184).

I have applied this patch (to the trunk version obtained here http://firebird.cvs.sourceforge.net/viewvc/firebird/OdbcJdbc/) and recompiled using Ms Visual Studio 2013. It has corrected the problem.

Tested with both 32 bits and 64 bits ODBC connection under Windows 7 64 bits.

Commented by: @alexpotapchenko

Jojakim, can you send final version of OdbcConvert.cpp (OdbcDesc.cpp, IscStatementMetaData.cpp etc.) with all applied patches (160, 161, 162, 180 etc.)?
Some your patches does not apply by turn.

Commented by: Jojakim Stahl (jstahl)

Hello, I attached the sources which I currently use to build my "own/private" version of the driver which I am using with our application. The sources are base on cvs head from 2015-02-25.
Nice that you are going to integrate the fixes, perhaps I can abandon my fork then.
Greetings

Modified by: Jojakim Stahl (jstahl)

Attachment: FbOdbc.zip [ 12982 ]

Commented by: @alexpotapchenko

Jojakim, thanks. I think your changes will be included to ODBC driver 2.1 (cvs head now).

Commented by: @alexpotapchenko

Fixed in CVS

Modified by: @alexpotapchenko

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.0.5 [ 10771 ]

Fix Version: 2.1 Beta [ 10410 ]

Modified by: @alexpotapchenko

status: Resolved [ 5 ] => Closed [ 6 ]