[freetds] How to set tsql's client character set
kjatwork at gmx.net
Fri Aug 11 10:11:36 EDT 2006
> Nice work!
> The goal is to make it unnecessary to declare the client charset in
> freetds.conf for a correctly configured machine. That is, we want to
> rely on the locale settings unless overridden by freetds.conf.
> Steve Langasek submitted a patch for 0.64 to do that but it was late in
> the release cycle. I eventually decided to defer it because there are a
> lot of permuations and I wanted to look at it more closely. :-(
> Please see the ML thread (subject "charset selection") starting April 1
> 2006. You'll see Steve's patch and our discussion. Have a look at it
> and test it out if you like. If you confirm it does what you want (and
> what I described above), that would encourage me to apply it.
I just went through the ML and found that stuff quiet confusing. I don't understand what's the difference between server/wire character set and client character set.
Sybase tools (isql, bcp) offer an additional option -J for specifying the client's character set. If that option is missing the platform's default is being used, if followed by a charset then that one is used, if -J is specified without parameter, then the server's characater set is used, whatever it might be (in the latter case no charset is being sent in the login record).
Hence the client does not have to know server's charset. The character set conversion is done on the server. If both character sets are equal no conversion is done otherwise the conversion rules applies (with or without conversion errors).
My suggestion is to use the approach above, without usage of any *.conf file (concerning char sets!).
I added those lines to populate_login procedure and it works fine (I added the X option because I didn't want to deal with how to provide a switch with an optional argument - that's for experts).
charset = "";
charset = (char *) malloc(strlen(optarg) + 1);
The only remaining thing to is to get *no* charset (binary 0-s) into the login record to implement -J without argument. I think it's no good idea to set iso_1 as default - which happens if charset is the empty string - although it might be a good guess in many cases, because if e.g. data are being bulked out and in data without character set conversion it's the perfect option, whatever the platform's character set might be.
If character set is important, it can be specified along with -J option.
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
More information about the FreeTDS