网上搜的方法,当时试了不行,后来同事试了下可以 NSStringEncoding *useEncodeing = nil; //带编码头的如utf-8等,这里会识别出来 NSString *body = [NSString stringWithContentsOfFile:filePath usedEncoding:useEncodeing error:nil]; //识别不到,按GBK编码再解码一次.这里不能先按
解决方法:()
/**
* 中文乱码问题:先用utf-8解码,再用GBK编码就可以了
*/
NSString *urlString = [User_Defaults objectForKey:@"zxUrl"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
[self.webview loadData:data MIMEType:@"text/html" textEncodingName:@"GBK" baseURL:url];
网友评论