Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS and UTF-8 support

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS and UTF-8 support
  • Date: Thu, 24 Jul 2008 10:18:50 -0400

Sebastien FLAESCH wrote:
>
> I think FreeTDS could support all single-byte or multi-byte character
> sets if:
>
> 1) The application (main) calls setlocale() to define the current
> charset for libc functions like mbtowc, wctomb, mblen (that would
> include UTF-8 support).

I think we are nearly already there. We use setlocale(3) to determine the
client encoding by default, and consult the freetds.conf "client charset"
property as an override.

Instead of the "mb" functions, we use iconv(3). We do sometimes depend on
strlen(3), which is one of many reasons that UCS-2 is not supported (yet)
as a client encoding. (Another reason is that the APIs sometimes assume
bytes == characters, or state that they return a pointer to a
null-terminated string. Another reason is I'm aware of only two operating
systems that use any form of wchar_t natively, and they're both
proprietary.)

> SQLPrepare(hp, (char *) "my SQL string in current SBCD or MBCS charset",
> SQL_NTS);
>
> would be mapped to:
>
> SQLPrepareW(hp, (wchar_t *) "my SQL string in UCS-2", SQL_NTS);

I don't think SQLPrepareW is necessary. SQLPrepare could do both jobs.

> WARNING: wchar_t on UNIX is 4 bytes while UCS-2 and wchar_t on Windonws
> is 2 bytes.

Thanks for that. I didn't know.

Regards,

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page