[freetds] How to set tsql's client character set

Lowden, James K james.k.lowden at alliancebernstein.com
Wed Aug 9 13:51:07 EDT 2006

> From: KJ
> Sent: Wednesday, August 09, 2006 5:45 AM
> I just successfully compiled and installed freetds 0.64 on cygwin.
> I'm able to get a connection to Sybase ASE as well as to MS SQL
> Server.  However I can't figure out how to tell the client (e.g.
> tsql) to use use a specific character set. Sybase ASE's character
> set is iso_1 and I tried to connect to Sybase using differnet
> character set specifications, e.g ISO-8859-1, iso_1. But no matter
> which character set I'm specifying, tsql always connects with
> iso646. As far as I can see, I compiled tsql with the GNU iconv
> library. Hence all the supported character set conversion should
> be available.  Does someone know how to specify the character set?
> tsql -C provides
> Compile-time settings (established with the "configure" script):
>                         Version: freetds v0.64
>  MS db-lib source compatibility: no
>     Sybase binary compatibility: unknown
>                   Thread safety: yes
>                   iconv library: yes
>                     TDS version: 5.0
>                           iODBC: no
>                        unixodbc: no
> Running tsql I get
> locale is "C" locale charset is "US-ASCII" Password:  Msg 2401,
> Level 11, State 2, Server ASE125, Line 0 Character set conversion
> is not available between client character set 'iso646' and server
> character set 'iso_1'.

Hrm.  Thank you for the problem report.  You've done everything right.
Somehow, the "client charset" is being ignored in favor of the locale
setting.  I don't know why that's happening.  I hope it's specific to
Cygwin & TDS 5.0.  

BTW, iconv doesn't normally get involved with Sybase servers.  When the
client connects to a Sybase server, it indiciates its preferred
encoding, which the server typically supports.  When the data arrive at
the client, iconv has nothing to do because the apparent "server
charset" is identical to the client's.  (That's why you get message 2401
from the server: it can't convert an 8-bit encoding to a 7-bit one.)  

Please try setting the locale (probably the LANG or LC_ALL, but see your
manual) to ISO 8859-1 and see if that helps.  



The information contained in this transmission may be privileged and
confidential 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