1
NSData *htmlData=[html dataUsingEncoding:NSUTF8StringEncoding];
TFHpple *htmlParser=[TFHpple hppleWithHTMLData:htmlData];

NSString *threadListXpathQuertString=@"//div[@id='postlist']/div";
NSLog(@"%@",threadListXpathQuertString);
NSArray *threadList=[htmlParser searchWithXPathQuery:threadListXpathQuertString];

html is a nsstring, when it runs at the last line code ,it occures error.

encoding error : input conversion failed due to input error, bytes 0x20 0x2D 0x20 0x44

encoding error : input conversion failed due to input error, bytes 0x20 0x2E 0x2E 0x2E

encoding error : input conversion failed due to input error, bytes 0x3C 0x2F 0x61 0x3E

encoding error : input conversion failed due to input error, bytes 0x3C 0x2F 0x61 0x3E

I/O error : encoder error Nodes was nil.

Community
  • 1
  • 1
leizh007
  • 33
  • 4

1 Answers1

0

i solved it. convert the gbk charset to utf-8 charset can solve this.

html=[html stringByReplacingOccurrencesOfString:@"gbk" withString:@"utf-8"]; 
Igal S.
  • 13,146
  • 5
  • 30
  • 48
leizh007
  • 33
  • 4