Subject Re: [firebird-support] Using Wide-Functions on unixODBC fails
Author Mark Rotteveel
Your question is probably better suited for the Firebird ODBC
Development mailinglist. See
http://www.firebirdsql.org/en/mailing-lists/ for subscription details.

Mark

On 10-4-2013 21:41, Daniel Vogelbacher wrote:
> Hi,
>
> when using the Firebird ODBC driver with unixODBC, the Wide-Functions
> like SQLExecDirectW fails.
>
> UnixODBC defines SQLWCHAR as a 2-Byte value. I've transformed my
> wchar_t* strings to UCS2 and call SQLExecDirectW() with them.
>
> Here is the trace (debug version):
>
> ----
> SQLExecDirectW
> Preparing statement:
> INSERT INTO FOO VALUES(NU
> Preparing statement:
> INSERT INTO FOO VALUES(NU
>
> HY000:1:-104:[ODBC Firebird Driver][Firebird]Dynamic SQL Error
> SQL error code = -104
> Unexpected end of command - line 1, column 24
> ----
>
> It seems that something in the ODBC driver truncates the
> statement to the half. A short look into the code shows this function
> inside the ConvertingString template (MainUnicode.cpp):
>
>
> SQLCHAR * convUnicodeToString( SQLWCHAR *wcString, int length )
> {
> size_t bytesNeeded;
> wchar_t *ptEndWC = NULL;
> wchar_t saveWC;
>
> if ( length == SQL_NTS )
> length = (int)wcslen( (const wchar_t*)wcString );
> ...
>
>
> I think the problem is that wcslen() expects a whar_t (4 bytes) sequence,
> while SQLWCHAR is 2 bytes long.
>
>
> Because I'm unsure if my code is correct, I've tested the same with
> python3 and pyodbc (which uses the wide-functions, too).
> This results in the same issue, so using the firebird odbc driver
> with pyodbc/python3 is impossible for the moment.
>
>
> Could anyone confirm this issue?
>
>
>


--
Mark Rotteveel