尽管文档说 XMLLite 无法处理不同的编码,但您似乎可以通过 using 来解决这个IMultiLanguage2
问题,文档中提到了这一点,但没有给出示例。
所以这里是如何启用它:
#include <mlang.h>
XMLLiteReader::XMLLiteReader(void)
{
mLanguage = NULL;
mXMLLiteReader = NULL;
mCOMInitialized = false;
HRESULT hr;
if(CoInitialize(NULL) != S_OK)
return;
mCOMInitialized = true;
if((hr = CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_ALL, IID_IMultiLanguage2, (void **)&mLanguage)) != S_OK)
return;
hr = CreateXmlReader(__uuidof(IXmlReader), (void**) &mXMLLiteReader, NULL);
if(hr != S_OK)
{
mXMLLiteReader = NULL;
return;
}
hr = mXMLLiteReader->SetProperty(XmlReaderProperty_MultiLanguage, (LONG_PTR)mLanguage);
}