使用Objective-C文本编码问题解析HTTP上的HTML/明文
我正在使用NSURLConnection解析一些纯文本/HTML,如下所示:使用Objective-C文本编码问题解析HTTP上的HTML/明文,html,objective-c,macos,http,encoding,Html,Objective C,Macos,Http,Encoding,我正在使用NSURLConnection解析一些纯文本/HTML,如下所示: NSURLResponse *response; NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; //I should find a better way to convert this string NSString *content
NSURLResponse *response;
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
//I should find a better way to convert this string
NSString *content = [NSString stringWithCString:[result bytes]];
我尝试过使用stringWithCString和stringWithUTF8String,但对于像“
或';
这样的特殊字符,我仍然会遇到奇怪的HTML格式错误
我确信有一些非常明显的更好的方法来解码文本,但我对ObjC非常陌生,对于谷歌搜索的目的有点不知所措。非常明显的答案是,要解析HTML,你需要一个HTML解析器。 如果有人来找我,我会提供我想要的