[freetds] Character encoding

James K. Lowden jklowden at schemamania.org
Wed Apr 27 19:34:45 EDT 2005


Conrad Schilbe wrote:
> I'm having an issue where certain characters are not properly encoded 
> when saving to the db. I believe it to be a character encoding issue 
> because the resulting character appears to be a UTF-8 representation of 
> the expected character.
> 
> I am noticing this specifically with the registered trademark character 
> and can almost certainly trace it back to freetds as I have trace the 
> query until point of execution. Although the everything seems fine when 
> testing the same query with tsql.

Because everything is fine with tsql, I suspect higher layers are doing
the translation.  A TDSDUMP log would record the encodings used during the
session, and show the data as the server sent them.  There is no
compiled-in default conversion to UTF-8 or anything like that.  If you
want UTF-8 (or any conversion at all, for that matter) you have to say so
in your freetds.conf.  

Unless you specify a client-side character set, libtds will assume -- for
purposes of dealing with the UCS-2 data in the TDS packets -- that the
client is using ISO 8859-1 a/k/a Latin-1.  

HTH.

--jkl


More information about the FreeTDS mailing list