Re: Status of UTF-8 support in 0.83 dev

Sebastien FLAESCH <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Organization Four J's Development Tools
Message-ID <[email protected]>
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
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.