iconv support

Brian Bruns camber at ais.org
Sun Nov 25 14:36:06 EST 2001



Well, I *finally* got around to finishing off iconv support (four day 
weekends are great).

It works like this:

. By default TDS 7.0 streams will have their high order byte stripped like 
  before.
. Support for iconv must be compiled in. (autoconf *should* pick up 
  whether you have it or not).
. iconv conversion needs to be turned on using the 'client charset' string 
  in the freetds.conf file.  Users of the old interfaces file will not be 
  able to use iconv conversion.
. Unfortunately iconv converts unconvertable characters to null, and thus 
  a mismatch of SQL and iconv charset will result in a truncation at the 
  first unconvertable character.  Solutions anyone?
. I'm a bit nervous on the multibyte support including UTF-8.  I tried  
  UTF-8 with sqsh and got garbage characters (SQSH is not unicode clean), 
  but I fear if the UTF-8 strings exceed the size of the column from which 
  they came there could be a buffer overrun in the application.  So, 
  please ensure your apps can handle it before using.  I'm looking at what 
  support needs to be added in ctlib/dblib (specifically ct_describe) to 
  alleviate this problem.  However, many apps will make assumptions based 
  on single character charsets, and dblib especially allow the apps to not 
  pass a buffer length when binding. Be careful!

Anyway, to turn it on, grab a new copy of FreeTDS from CVS, build it,  and 
modify your freetds.conf file like so:

[sqlserver]
	tds version = 7.0
	host = ntbox.localdomain.com
	port = 1433
	client charset = ISO-8859-1

The 'client charset' will turn on client conversion to and from the 
specified charset (ISO-8859-1 in this case).  To find a list of supported 
character sets, run 'iconv --list' for linux, consult your documentation 
for other systems (and post it here so I can update the user guide!).

I'd be especially interested to hear from folks using single character 
cyrillic sets to see if this solves the problem for you guys.  This seems 
to be where the question comes up most often.

Oh and one last thing, jkl if your reading, where in the user guide to you 
want all this documented?  I updated the freetds.conf settings table, but 
I'd like to do a full write up.


Enjoy,

Brian




More information about the FreeTDS mailing list