我必须解码HTML字符串,但响应不顺利。这是我必须解码HTML字符串的网址:http://www.delvetech.org/sharpkirana/sharpapi/aboutApi.php
。
我的代码如下:
NSString *HTML = [NSString stringWithFormat:@"<html>\n"
"<head>\n"
"<style type=\"text/css\">\n"
"body {font-family: \"%@\"; font-size: %@; color:#%@;}\n"
"</style>\n"
"</head>\n"
"<body>%@</body>\n"
"</html>",
font.familyName, @(font.pointSize), colorHexString, htmlBodyString];
return HTML;
我的代码中是否存在问题或HTML字符串错误?
答案 0 :(得分:0)
NSAttributedString *HTML=[[NSAttributedString alloc] initWithData:[HTMLCodeString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];
retutn HTML;