现在的位置: 首页 > 综合 > 正文

iOS平台下ZXing类库GBK乱码解决办法

2013年12月07日 ⁄ 综合 ⁄ 共 692字 ⁄ 字号 评论关闭

最近遇到这个问题,找了一下资料,没有现成的方案,在这里分享一下心得,方便后来人。


ZXing在iOS平台下遇到GBK字符串产生乱码的原因是ZXing没有对GBK编码字符作判断,于是遇到GBK编码字符串时使用错误的编码,所以我们需要对源码作一些修改。


打开ZXingWidget工程
1.找到DecodedBitStreamParser.h 添加GBK编码变量

?
1
2
3
4
5
6
7
static

c*****t
char

*ASCII;
static

c*****t
char

*ISO88591;
static

c*****t
char

*UTF8;
static

c*****t
char

*SHIFT_JIS;
static

c*****t
char

*EUC_JP;
 
static

c*****t
char

*GBK;
//
添加



2.在DecodedBitStreamParser.cpp中

?
1
2
3
4
5
6
7
c*****t
char

*DecodedBitStreamParser::ASCII =
"ASCII";
c*****t
char

*DecodedBitStreamParser::ISO88591 =
"ISO-8859-1";
c*****t
char

*DecodedBitStreamParser::UTF8 =
"UTF-8";
c*****t
char

*DecodedBitStreamParser::SHIFT_JIS =
"SHIFT_JIS";
c*****t
char

*DecodedBitStreamParser::EUC_JP =
"EUC-JP";
 
c*****t
char

*DecodedBitStreamParser::GBK =
"GB2312"

抱歉!评论已关闭.