首先查看网页源码,查找
charset
将不是utf-8的设置为utf8
// 替换网页源码中不是utf8的编码 NSString *utf8HtmlStr = [html stringByReplacingOccurrencesOfString:@"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=GBK\">" withString:@"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"]; // 使用utf8的data NSData *htmlDataUTF8 = [utf8HtmlStr dataUsingEncoding:NSUTF8StringEncoding];
时间: 2024-11-13 03:40:17