Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieving unicode with odbc

Status
Not open for further replies.

cgillin

Programmer
Mar 20, 2003
58
0
0
US
I have a table that has arabic, japanese, utf8 and ascii strings in it. When I try and rerieve those strings using the windows odbc driver, the ascii and since byte utf8 characters come back fine, the arabic and japanese are returning as single byte characters. I read on microsofts page that odbc versions before 3.7 are considered non-unicode. When I look at the version of the odbc administrator it says 3.5. Is there a newer version of the sqlserver odbc driver or windows odbc administrator that I would need?

Is there some way to specify what the client charset is? I'm using SQLGetData with a target type of SQL_C_WCHAR.

Right now I have xp SP2 that has mdac 2.8 SP1.

Thanks for your help.
 
Are you sure it is the driver?

MS says that it's sqlserver driver is 3.51.

Enterprise Manager Uses ODBC to connect to SQL.
Does the data show up in Enterprise Manager if you "Open" the Table?

If it does, it might be the encoding of your cleint that is the issue.

Just a thought. Hope it helps.


Rob
 
Actually it's not the driver. Through Enterprise Manager the characters are fine. There isn't a way to set a client encoding though is there? It seems like everything i'm retrieving is Latin1 encoding.
 
I wrote an application in C that will just dump all rows of the table into xml.
 
Ahhh ... the xml document has an attribute that should let you specify encoding.

I can't remember what it is.. If I can find it I will dig it out and post bavck.


Rob
 
Thanks for your help so far Rob.

The problem is before I create the xml though. If I just simply print the data that I retrieve it's looks as though it's encoded as Latin1.

Another thing I noticed, when I use Export Data to dump the contents of the table to a file, the encoding is incorrect in just the same way. I am selecting UNICODE as the file type.

I think there is something real simple that I'm missing here.

Thanks again.
 
Correction, when I use wordpad to view the file that I created using Export Data it's fine. I read that sql server uses UCS-2 encoding, so why, when I convert the data I get through odbc from UCS-2 to UTF-8 would I not get back what's actually in the table?

Not sure if how clear I'm being right now, I'm a little lost at this point :(

Thanks
 
c...

I have to admit, you are now going past anything I know. I am more of a VB/Dot Net person..

Hopefull someone else can jump in here.. but have you tried reading it directly into a file.. or are you bringing it into a control?


Rob
 
Rob

Thanks a lot for helping out.

Not sure what you mean by bringing it into a control. I'm not really sure what is going on but here's what I've got so far...

I have a table that has arabic, japanese, accented and regular ascii string. When I try and use odbc to fetch these string I've noticed two things. Looks like it may be using an ansii driver because all characters are encoded in Latin1, another thing I noticed now that I've created more ascii strings is, only the first character of the string is being returned.

Not sure if that tips you off to anything Rob. If anyone else has any ideas I'd really appreciate hearing them.

Thanks a lot

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top