[freetds] Status of UTF-8 support in 0.83 dev

Sebastien FLAESCH sf at 4js.com
Thu Aug 14 10:24:47 EDT 2008

About ParameterType in SQLBindParameter:

 From my understanding, if on Windows you write a "UNICODE" UCS-2 ODBC
application using wchar_t/WCHAR, you have to bind using:


But what about UTF-8 ODBC applications in FreeTDS?

Does FreeTDS ODBC consider that UTF-8 is an equivalent for the Microsoft
"UNICODE" and therefore must be bound with SQL_C_CHAR + SQL_W[VAR]CHAR?

IBM DB2 CLI says UTF-8 data can be bound with SQL_[VAR]CHAR:


Microsoft says SQL_W[VAR]CHAR has to be used for "Unicode character string" (I guess they talk about UCS-2):


What's the right way?


Sebastien FLAESCH wrote:
> James,
> When I print the client and the server charset in tds_convert_string()
> called from tds_put_data(), I see:
>   char_conv->client_charset.name = "UTF-8"
>   char_conv->server_charset.name = "CP1252"
> I expected UCS-2 for the server charset...????
> Hence it's normal that the conversion of non-CP1252 compatible chars
> like 鴻 result in error...
> I appears that curcol->char_conv points to the client2server_chardata
> TDSICONV structure, because in tds_set_param_type(), the data type is
> not identified as a UNICODE type...
> So when binding the buffers with sqltype SQL_[VAR]CHAR, it appears that
> the Sybase type used is not "UNICODE"...
> Should I then bind with SQL_WCHAR / SQL_WVARCHAR?
> I made a little test (attached, with log)... still failing.
> Seb
> ------------------------------------------------------------------------
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

More information about the FreeTDS mailing list