我使用libxml2
中的xmlTextWriter
来编写一些xml文件。我需要将西里尔字符写入它们中。 我做这种方式:将西里尔文字符写入xml文件
xmlTextWriterStartDocument(writer, NULL, "utf-8", NULL);
...
snprintf(buf, sizeof(buf), "%s", "тест");
xmlTextWriterWriteAttribute(writer,
(const xmlChar*)"test_attribute",
(const xmlChar*)buf);
但是当我打开生成的XML文件,我看到我的文字的HTML表示,就像这样:test_attribute="тест"
我该如何解决这个问题?
对我来说似乎是正确的。文本正在编码。 decl中存在什么编码? – BigMike 2012-07-12 09:58:31
这是utf-8。我已经将这添加到了我的问题中。 – hank 2012-07-12 10:02:15