Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91473
  • 博文数量: 25
  • 博客积分: 1535
  • 博客等级: 上尉
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-06 00:19
个人简介

艹 不设置头像还不让发博客了??

文章分类

全部博文(25)

文章存档

2011年(1)

2009年(13)

2008年(11)

我的朋友

分类: Mysql/postgreSQL

2009-04-19 22:58:13

又折腾了一天,才发现使用latin1作为连接字符集是兼容性最好的

RO客户端给出来的名称是GBK的,而我的系统是UTF8,而且我还选择了UTF8作为了数据库连接的字符集。当我忙活了老半天去想办法自己转化字符串到utf8之后,却发现utf8的字符也不能正确的存取。 恍然间,突然想试试看latin1连接,就象其他人那样,从此发现乱码消失了。

一天阿!

        mysql_options(real_conn, MYSQL_SET_CHARSET_NAME, "latin1");

        mysql_query(real_conn, "INSERT INTO `char` (`char_id`, `account_id`, `char_num`, `name`, `zeny`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,`max_sp`, `sp`, `hair`, `hair_color`, `last_map`, `last_x`, `last_y`, `save_map`, `save_x`, `save_y`) VALUES ('1', '1', '1', '天', '1', '1', '1', '1', '1', '1', '1', '1', '1','1', '1','1', '1', 'a', '1', '1', 'b', '1', '1')");


        mysql_query(real_conn, "select * from `char`");
        res = mysql_store_result(real_conn);
       
        long row_num = mysql_affected_rows(real_conn);
        long col_num = mysql_field_count(real_conn);
       
        printf("row:%lu col:%lu\n", (unsigned long)row_num, (unsigned long)col_num);
        for(int i = 0; i < row_num; ++i)
        {
                MYSQL_ROW row_data = mysql_fetch_row(res);
                for(int j = 0; j < col_num; ++j)
                        printf("%s\t", row_data[j]);
                       
                printf("\n");
        }
        mysql_free_result(res);
        mysql_close(real_conn);

阅读(1043) | 评论(0) | 转发(0) |
0

上一篇:Ro_04092009

下一篇:ubuntu/linux flash中文乱码

给主人留下些什么吧!~~