[freetds] connecting and character sets

James K. Lowden jklowden at freetds.org
Wed Sep 26 22:37:43 EDT 2007


Bryan Olmstead (imap) wrote:
> i recently ran a query that returned a row with a question mark and the
> line: "WARNING! Some character(s) could not be converted into client's
> character set. Unconverted bytes were changed to question marks ('?')".
> 
> searching google and the mailing list i found that i should be able to
> fix this by either setting "client charset" in the freetds.conf file or
> the LANG environment variable.  i've tested this out and neither seems
> to have worked as i still receive the warning and the question mark.  if
> anyone could give me some advice i would greatly appreciate it.
> 
> and before i forget, it's version 0.64 on slackware connecting to mssql.
...
> just in case anyone is wondering, these are the en_US currently:
> 
> en_US
> en_US.iso88591
> 
> and the freetds.conf section:
> 
> [test]
>         host = 127.0.0.1
>         port = 1434
>         tds version = 7.0
>         client charset = UTF-8

I think what's happening is caused by setting LC_ALL to POSIX.  That
supersedes freetds.conf and tells libc you want ASCII (a/k/a
ANSI_X3.4-1968).  

http://www.opengroup.org/onlinepubs/007908799/xbd/envvar.html

	"LANG
This variable determines the locale category for native language, local
customs and coded character set in the absence of the LC_ALL"

I.e. LC_ALL supersedes LANG.  

tsql reports the results of setlocale(3) and nl_langinfo(3).  If you set
your LC_ALL to en_US.iso88591 or en_US.UTF8 (maybe, depends on your iconv
implementation) tsql should report using it instead of 'locale charset is
"ANSI_X3.4-1968"'.  

HTH.

--jkl


More information about the FreeTDS mailing list