Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Unicode from Linux/OS X to SQL Server nvarchar
  • Date: Mon, 27 Jul 2009 23:18:57 -0400

Ingmar Koecher wrote:
>
> 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?

FreeTDS engages an iconv library to convert between server and client
encodings. In principle, you should be able to define any client
encoding, bind your parameters character buffers, and call your
procedures.

It has worked for query processing and bcp for years. Only more recently
did parameter binding get attention.

> 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.

The last thing you want to do is somehow end up with UTF-8 data on a
Microsoft server, since it doesn't recognize that as a valid encoding.

The DBMS does the storing and decides the format. NVARCHAR columns are
UCS-2; VARCHAR some flavor of single-type "code page".

What you want is UTF-8 on the client and NVARCHAR on the server, and
FreeTDS in between to handle the conversion. I'm not sure how well this
currently works in practice, but it should. I recommend trying a recent
snapshot. Definitive problem reports are almost as welcome as working
patches. :-)

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page