gpt4 book ai didi

c++ - MSXML4 和设置编码字符串

转载 作者:行者123 更新时间:2023-11-28 08:27:12 25 4
gpt4 key购买 nike

我使用 MSXML4 生成 XML。

我正在尝试将编码值设置为 UTF-8。

这是我的代码:

const _bstr_t k_XML_Tag_Name ("xml");
const _bstr_t k_Processing_Tag_Name ("version=\"1.0\" encoding=\"utf-8\"");

MSXML2::IXMLDOMProcessingInstructionPtr pProccessingInstruction = m_pXmlDoc->createProcessingInstruction(k_XML_Tag_Name, k_Processing_Tag_Name);

HRESULT result = m_pXmlDoc->appendChild(pProccessingInstruction);

result总是 S_FALSE预处理字符串为:

<?xml version="1.0"?>

那么,为什么没有显示编码字符串?

最佳答案

当您将 xml 保存到文件中时,您应该会看到 <?xml version="1.0" encoding="UTF-8"?>声明。然而,根据这个article , 当你使用 XML文档的属性返回的声明不包含编码,这似乎是设计使然。这是您遇到的行为吗?文章指出:

This is normal. The reason it did this is so that you can turn around and call LoadXML with this string and it will work. If it does not do this, LoadXML will fail with the error message: "Switch from current encoding to specified encoding not supported."

关于c++ - MSXML4 和设置编码字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3587474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com