我目前正在使用 Hpple 进行一些 iOS HTML 解析,但希望为 HTML 字符串提供预期的编码,但无法找到参数的可能值。 Hpple库有一个功能:
+ (TFHpple *) hppleWithXMLData:(NSData *)theData encoding:(NSString *)theEncoding;
它使用 libxml2 的 htmlReadMemory :
htmlDocPtr htmlReadMemory(const char * buffer,
int size,
const char * URL,
const char * encoding,
int options);
函数的文档和 libxml2 的 encoding support documentation 都不是说出有关可能值的任何内容以及未指定编码(nil)时使用的默认编码是什么。
有什么建议吗?
最佳答案
这取决于您的 libxml2 版本的配置。如果您使用 libiconv 构建 libxml2或 ICU,您将获得这些库支持的所有编码。没有 iconv 或 ICU,libxml2 有 native support用于:
UTF-8
UTF-16 UTF-16LE
UTF-16BE
ASCII US-ASCII
ISO-8859-1
ISO-8859-2
ISO-8859-3
ISO-8859-4
ISO-8859-5
ISO-8859-6
ISO-8859-7
ISO-8859-8
ISO-8859-9
ISO-8859-0
ISO-8859-11
ISO-8859-13
ISO-8859-14
ISO-8859-15
ISO-8859-16
关于html - libxml2 -> HTMLparser.h -> htmlReadMemory 中编码的可能值是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33957292/