PDA

View Full Version : Need some hints for dealing with MS ODBC driver and utf8 data



Wurgl
18th March 2013, 11:33
Hello!

I need to fill some MS SQL Server (2008) with data containing UTF8 characters. For example german umlauts, but also a lot of other characters. Any 8-bit codepage is not an option :-(

So far everything works fine as long as the data I fill into the database (and read form it) are 7 bit chars. Somehow I do not find those pages which help me to isolate the problem.

Question:
Do I need to add some string like "CHARSET=utf8" when opening the connection?
Do I need to set the charset later when I open a specific database (with the USE <database> statement) and how?
Do I nee those database types nchar and ntext/nvarchar or does it work with char and text/varchar?

Anything else?

Wurgl
20th March 2013, 18:25
Found the problem.

A statement like "INSERT INTO xxTest (x_nchar) VALUES ('Gülle')" corrupts that Umlaut, whereas "INSERT INTO xxTest (x_nchar) VALUES (:nch)" and bind that string "Gülle" to nch works fine.