Skip to Content.
Sympa Menu

freetds - [freetds] Unicode from Linux/OS X to SQL Server nvarchar

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Ingmar Koecher <ingmar.koecher AT gmail.com>
  • To: FreeTDS AT lists.ibiblio.org
  • Subject: [freetds] Unicode from Linux/OS X to SQL Server nvarchar
  • Date: Sun, 26 Jul 2009 22:00:27 -0400

Hello,

I'm working on a project where unicode data is written to a SQL Server
database, e.g. a nvarchar field. Since SQL Server only supports UCS-2
encoding, I am inclined to use the SQL_WVARCHAR data type to bind the
parameter.

Since Linux is using UTF-8, I am converting the UTF-8 string to UTF-16 and
then trying to bind with SQLBindParameter. This works with the MySQL ODBC
driver, but not with FreeTDS where I get error "[FreeTDS][SQL Server]Invalid
data type (0) (ret=-1)".

I found one post where it was suggested that one use UTF-8 as FreeTDS
doesn't support UCS-2, but I am confused as to how this would work since SQL
Server doesn't support UTF-8. Does FreeTDS convert it from UTF-8 to UCS-2?

Basically, I am curious what the recommended way is to store unicode data
(whether it's UTF-8 or UTF-16) in a SQL Server database nvarchar field.

Thank you in advance for any suggestions.


Ingmar.




Archive powered by MHonArc 2.6.24.

Top of Page