2021SC@SDUSC
修改文件 zbar/qrcode/qrdectxt.c:
latin1_cd=iconv_open("GB18030","UTF-8");
/*But this one is often used, as well.*/
sjis_cd=iconv_open("GB2312","UTF-8");
/*This is a trivial conversion just to check validity without extra code.*/
utf8_cd=iconv_open("UTF-8","UTF-8");
...
enc_list[1]=sjis_cd;
enc_list[0]=latin1_cd;
enc_list[2]=utf8_cd;
重新编译运行后,正确输出“http123测试456”
UTF-8转GB18030实现:
1. 需要一个GB18030字符集,其实就是一个数组,实现代码如下(VS下编译)
调用UnicodeToGB18030Table函数生成一个GB18030字符集数组。
1 char* UnicodeToGB18030String(const wchar_t* unicode_str)
2 {
3 UINT code_page = 54936 ; //GB2312 :936 GB18030: 54936
4 int len=WideCharToMultiByte(code_page,0,unicode_str,-1,NULL,0,NULL,NULL);
5 char* buf=new char[len+1];