Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Sebastien FLAESCH <sf AT 4js.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Status of UTF-8 support in 0.83 dev
  • Date: Thu, 14 Aug 2008 17:09:14 +0200

James K. Lowden wrote:
Sebastien FLAESCH wrote:
From my understanding, if on Windows you write a "UNICODE" UCS-2 ODBC
application using wchar_t/WCHAR, you have to bind using:

SQL_C_WCHAR + SQL_W[VAR]CHAR

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

I agree with IBM.
"Wide" characters have a fixed width, usually 16 bits. UTF-8 has a
variable width and for the most part can be treated like ASCII (strlen(3)
et al.). Declaring UTF-8 as SQL_C_WCHAR incorrectly tells the driver
there's a character in every two bytes.

Oh take care, actually there are 2 type specifications in SQLBindParameter:

SQLRETURN SQLBindParameter(
SQLHSTMT StatementHandle,
SQLUSMALLINT ParameterNumber,
SQLSMALLINT InputOutputType,
SQLSMALLINT ValueType, -- This is the C type
SQLSMALLINT ParameterType, -- This is the SQL equivalent
SQLULEN ColumnSize,
SQLSMALLINT DecimalDigits,
SQLPOINTER ParameterValuePtr,
SQLINTEGER BufferLength,
SQLLEN * StrLen_or_IndPtr);

For sure, when using (char *) / UTF-8, ValueType *must* be SQL_C_CHAR,
not SQL_C_WCHAR... (that one is for wchar_t).

I was talking about ParameterType...

Should it be SQL_W[VAR]CHAR or SQL_[VAR]CHAR when binding UTF-8?




--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds






Archive powered by MHonArc 2.6.24.

Top of Page