Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AllanSQL
Starting Member
5 Posts |
Posted - 2008-07-03 : 18:30:29
|
| Dear Friends,How do I know if I fetch Japanese (Kanji – Chinese char) correctly from the SQL database table?Here is my situation:(1) Table Column Japanese (UTF 8) and English/Numbers (UTF 8)From SQL server management studio I can do the sql query and get the following in the result window.DB Table:985 ??? ??? ???2??10-1 2-10-1column type is nvarchar.(2) I use QDBC SQL API, but can not fetch Japanese correctly.SQLHSTMT handle …SQLExecDirect (handle, u_sql, sql.size());SQLBindCol (hanlde, ColNum, SQL_C_DEFAULT, &aBuffer), sizeof(aBuffer) - 1, &someLength));SQLFetch (hanlde)union DataBuffer{ bool b; short s; int i; double d; CHARBUF str; // typedef char CHARBU[1024] TIMESTAMP_STRUCT datetime;} aBuffer;From my debug window I can see the English nvarchar columns are fetch into char buffer correctly.aBuffer.str 0x0464b620 "Higashimorokata District, Miyazaki" char [1024]However, the column with Japanese seemed not fetched correctly. I have all the ? marks in the char buffer. I think that it should be some Square symbols.aBuffer.str 0x04673f30 "???" char [1024] (it is supposed to???).Question: How can I verify what I got is correct or not ? |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-07-04 : 21:15:26
|
| You need kind of encoder. |
 |
|
|
AllanSQL
Starting Member
5 Posts |
Posted - 2008-07-06 : 17:28:54
|
| Thanks for your comments. Can you be specific ?Here I don't need to dispay the text correctly. I just need to retrieve the text correctly.What I heard from China are(1) Using char for the receiving buffer is the correct because the programmers in China do use char as the type of the receiving buffer.(2) I was told the DB table field (nvarchar) should be populated in the unicode format. But I assume if I use char as the type of the receiving buffer, the unicode of the field (in Japanese) in the DB table has to be UTF 8. Is it correct ? I have not 100% confirmed that the unicode in my DB table for Japanese is UTF 8 ( it may be UTF 16). Thanks and regards. |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-07-06 : 18:16:00
|
| 1. Depends on collation used, need store them in unicode column if you use different collation.2. Unicode data can't store in char type column since it uses two bytes for a character. |
 |
|
|
|
|
|
|
|