Re: Unicode from Linux/OS X to SQL Server nvarchar

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.