[freetds] Unicode from Linux/OS X to SQL Server nvarchar
Ingmar Koecher
ingmar.koecher at gmail.com
Sun Jul 26 22:00:27 EDT 2009
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.
More information about the FreeTDS
mailing list