Skip to Content.
Sympa Menu

freetds - [freetds] Character conversion issues

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Chuck Bearden <cfbearden AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Character conversion issues
  • Date: Thu, 28 Oct 2004 12:57:58 -0500

I am using freetds-0.63.dev.20041026 with libiodbc-3.51.2 and mx.ODBC
2.0.6 on Red Hat Linux of some recent flavor.

I have a lot of data (including many non-English names) in a
PostgreSQL database, encoded as UTF-8. I want to insert this data
into an MS SQL Server, but I am giving myself headaches over this
problem. I am not sure what combination of freetds.conf settings and
input format for the mx.ODBC/MS SQL statements to use.

I can pass in UTF-8 data to mx.ODBC/MS SQL, or I can convert to UCS-2
(or UCS-2LE) before passing it in. What should I set my client
charset to, and what encoding should I pass in?

Here is my server config in freetds.conf:

[IfSH_Server7]
host = mssql.university.edu
port = 1433
tds version = 7.0
client charset = UTF-8

Trying to insert the UTF-8 data from PostgreSQL unconverted into MS
SQL yields this exception:

mxODBC.OperationalError: ('S1000', 2402, "[FreeTDS][SQL Server]Error
converting client characters into server's character set. Some
character(s) could not be converted.", 4579)

I can provide a TDSDUMP log of this if it would be helpful.

Using iconv_codec from within Python, I am able to convert the same
data UTF-8 -> unicode -> UCS-2LE without problems.

If I change the client charset to UCS-2LE, I cannot even connect to MS SQL:

mscx = mxodbc.DriverConnect("DSN=%s;UID=%s;PWD=%s" % (d,u,p))
mxODBC.OperationalError: ('08S01', 20004, '[FreeTDS][SQL Server]Read
from SQL server failed.', 6044)

What am I doing wrong?

Chuck




Archive powered by MHonArc 2.6.24.

Top of Page