[freetds] How to get UTF-8 back in application

Lowden, James K LowdenJK at bernstein.com
Tue Jul 19 14:46:01 EDT 2005


> From: Daniel Fazekas
> Sent: Tuesday, July 19, 2005 11:18 AM
> 
> On Jul 19, 2005, at 15:57, bohica at ntlworld.com wrote:
> > BUT tsql still does:  locale is "en_US" using default charset
> > "ISO-8859-1"
> >
> > 14:51:55.663481 iconv to convert client-side data to the
"ISO-8859-1"
> > character set I'm not as bothered about tsql; I only tried it
> > when I could not get client charset picked up from isql and
> > thought it might work better with client charset.
> 
> Hmm. Is it possible tsql would ignore the client charset as configured
> in freetds.conf even when you correctly use the -S option? It
> appears it prefers getting the client charset from your locale
> settings.

Yes, it's possible.  It's true:

    292         locale = setlocale(LC_ALL, NULL);
    293
    294 #if HAVE_LOCALE_CHARSET
    295         charset = locale_charset();
    296 #endif
    297 #if HAVE_NL_LANGINFO && defined(CODESET)
    298         if (!charset)
    299                 charset = nl_langinfo(CODESET);
    300 #endif
...
    400         /* if it's a servername */
    401
    402         if (servername) {
    403                 tds_set_user(login, username);
    404                 tds_set_app(login, "TSQL");
    405                 tds_set_library(login, "TDS-Library");
    406                 tds_set_server(login, servername);
==> 407                 tds_set_client_charset(login, charset);
    408                 tds_set_language(login, "us_english");
    409                 tds_set_passwd(login, password);
    410                 if (confile) {
    411                         tds_set_interfaces_file_loc(confile);
    412                 }

That's meant as a test of the host OS's locale support.  If you delete
line 407, tsql should respect the freetds.conf setting.  

The calls to locale_charset() and nl_langinfo() should be in libtds, to
establish a default client encoding if none is specified in
freetds.conf.  But they're not there yet, and TODO is a little out of
date on the subject....

--jkl




-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s) named
above. If you are not the intended recipient, or an employee or agent responsible
for delivering this message to the intended recipient, any review, dissemination,
distribution or duplication of this communication is strictly prohibited. If you are
not the intended recipient, please contact the sender immediately by reply e-mail
and destroy all copies of the original message. Please note that we do not accept
account orders and/or instructions by e-mail, and therefore will not be responsible
for carrying out such orders and/or instructions.  If you, as the intended recipient
of this message, the purpose of which is to inform and update our clients, prospects
and consultants of developments relating to our services and products, would not
like to receive further e-mail correspondence from the sender, please "reply" to the
sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas, New York,
NY 10105.


More information about the FreeTDS mailing list