Skip to content
This repository was archived by the owner on Jul 23, 2020. It is now read-only.

GBK编码的HTML字符串初始化Ji后里面的内容全乱码了 #22

Closed
zixun opened this issue Nov 13, 2015 · 4 comments
Closed

GBK编码的HTML字符串初始化Ji后里面的内容全乱码了 #22

zixun opened this issue Nov 13, 2015 · 4 comments

Comments

@zixun
Copy link

zixun commented Nov 13, 2015

网页是GBK编码的,然后我这样初始化Ji

 let NSGBKStringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.GB_18030_2000.rawValue))
 var htmlString = String(data: data!, encoding: NSGBKStringEncoding)
 let ji = Ji(htmlString: htmlString!, encoding: NSGBKStringEncoding)

我这样转换后ji里的内容中文的全乱码了,不知道为什么

网站是梦幻西游论坛:http://my.netease.com/forum.php

@honghaoz
Copy link
Owner

@zixun Thanks for your issue, I'll take a look on that. Not sure whether it's related to this issue #5 (comment)

@zixun
Copy link
Author

zixun commented Nov 14, 2015

@honghaoz OK,thank you~~ waiting for you~

@zixun
Copy link
Author

zixun commented Nov 14, 2015

@honghaoz I found the reason!! Its not the mistake of Ji,but me.
the HTML String from Web is based on GBK,but I change some HTML code by

 stringByReplacingOccurrencesOfString: withString:

and this api return a NSUTF8StringEncoding String.

if I tell the Ji the string encoding is UTF8,everything will work well.
if I not call the string api above,and tell Ji the encoding is GBK,it also work well~

@honghaoz
Copy link
Owner

@zixun Ahaha, cool, thanks for your responding! I believe this issue could be closed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants