[freetds] SQLBindParameter() does not work with UTF-8 ?!
ZIGLIO, Frediano, VF-IT
Frediano.Ziglio at vodafone.com
Fri Oct 10 10:59:36 EDT 2008
>
> Problem: My client ODBC application needs to bind parameters which are
> UTF-8 encoded to SQL insert/update statements.
> I have set ClientCharset to UTF-8 in freetds.conf.
>
> I did some tests with Version 0.82 of FreeTDS and SQL Server 2005.
> Seemed to work, but not with a short UTF-8 String like '€'.
> '€' is 3 bytes long in UTF-8 encoding.
>
> If I called
> SQLBindParameter( , ,SQL_C_CHAR, SQL_WVARCHAR, n, 0, , , &ind )
> with n=1 and *ind=3 I got an error message. iconv was not able to
> convert '€' and SQL Server complains also ...
>
> Calling with n=3 and *ind=3 succeeds but inserts the string '€ ' into
> the database because the Server pads with 2 blanks to the
> requested size
> of 3 CHARS.
>
> Setting *ind=SQL_NTS did not help.
>
> I have tested version 0.83dev 2008-10-09 also: It did not work at
> all using UTF-8 strings with non single byte UTF-8 characters.
>
> So I have had a look at what is going on inside the FreeTDS code
> (ver. 0.83dev) and found that the problem arises due to insufficient
> buffer space for the bounded parameter.
>
> I solved the problem with very small changes to tds/mem.c and
> odbc/sql2tds.c (see attached patch). For me it works now.
>
> Any comments on this issue ?
>
> Best regards,
> Norbert
>
>
It's strange that every time you implement a feature someone ask for another... well, this means that previous works as expected I hope :)
WVARCHAR is currently in progress. I don't think is supported by 0.82 and have some problems (there is a failing test) under CVS HEAD. Test related to your problem should be utf8, I'll test with your string.
Actually I'm quite busy so I have no timeline for this issue.
freddy77
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3129 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20081010/5908304c/attachment-0001.bin
More information about the FreeTDS
mailing list