In the recent open-source project of yymysqlsdk, Chinese support is not in place. Therefore, it took 1.5 days to analyze various Chinese processing conditions.
1. First confirm your mysql configuration file, my. ini (only for windows) configuration, if not, add
[Client]
Default-character-set = gbk (it is used to support Chinese characters when developing the client program. If it is set to utf8, I have not verified it. I will verify it later, haha)
[Mysql]
Default-character-set = utf8
[Mysqld]
Default-character-set = utf8
2. For database encoding attributes, select utf8. I am using naticat mysql.
3. Right-click the table and choose "query table information"> "ddl". Does the system see "ENGINE = InnoDB default charset = latin1 ;"
By the way, this is the default encoding method used by naticat when designing a table. Please do not change this encoding method as needed. latin1 is compatible with utf8)
4. Then, use vc to develop the client program. After real_connect, execute the encoding settings, mysql_query (xxx, "set names latin1 ");
5. Check the code,
View plain
Int rows = mysql_num_rows (res );
Int fields = mysql_num_fields (res );
For (int I = 0; I <rows; I ++)
{
MYSQL_ROW row = mysql_fetch_row (res );
Unsigned long * lengths = mysql_fetch_lengths (res );
For (int j = 0; j <fields; j ++)
{
Printf ("% s \ n", row [j]);
6. At this time, the output is utf8 encoded, Chinese
The above is my summary. I would be honored to help you.