Skip to Content.
Sympa Menu

freetds - Re: config->char_set vs. config->client_charset?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Steve Langasek <vorlon AT netexpress.net>
  • To: TDS Development Group <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: config->char_set vs. config->client_charset?
  • Date: Sun, 22 Sep 2002 11:06:59 -0500

A good morning for talking to oneself...

On Sun, Sep 22, 2002 at 02:27:55AM -0500, Steve Langasek wrote:
> I've been looking through the locale code (see? this thread isn't dead
> :), to try to work out how I can get full integration with system locales
> and avoid the need for an /etc/freetds/locales.conf. I've gotten
> nl_langinfo() working quite well for both charsets and date formats, but
> when I trace the code farther, I see that the locale charset is only used
> to initialize one of two charset variables in the config -- and not the
> one that's used for iconv! Since the client charset is definitely part
> of the locale settings (moreso, I dare say, than the on-the-wire
> charset), would it be reasonable to add an additional 'client charset'
> option to the locales.conf format & associated data structure?

Well, I was close enough to having this working that I could smell it, so
I went ahead and implemented it locally even if it's not correct. ;) The
results are quite beautiful -- load up a copy of sqsh in UTF-8 locale,
pass a random bit of UTF-8 data to an INSERT statement, and it's visible
just fine on the SQL server (well, modulo the fact that I have more
complete Unicode fonts on my Linux workstation... :).

There's a pretty visible bug on SELECT, though -- for whatever reason,
all of the multibyte characters are being rendered to the terminal as
either � (the UTF-8 marker for an invalid multibyte sequence) or as ?
(an unrepresentable character). The ones represented with a '?' in sqsh
are also seen that way when viewing the data on the server, so that may
be a problem with the initial UTF-8 -> UCS-2 conversion; I'll have to
look into it more to see. Doesn't bother me too terribly much, I'm
tickled that everything works as well as it does at this point.

Also, to make use of the system locale settings, the application's locale
has to be *initialized* by a call to setlocale(). Right now I'm doing
this in the library just before my calls to nl_langinfo(), which is an
awful thing to be doing; but it's clear that sqsh doesn't currently do
locale initialization on its own. I'll make a quick patch for sqsh to do
that; anyone using FreeTDS bindings from another language (e.g., PHP or
Perl) should make use of that language's locale support to enable this
behavior. ('setlocale()' in PHP, 'use locale' in Perl).

Cheers,
Steve Langasek
postmodern programmer

Attachment: pgpx0RDitQvYw.pgp
Description: PGP signature




Archive powered by MHonArc 2.6.24.

Top of Page