tinyxml2
tinyxml2 copied to clipboard
在系统语言为繁体中文情况下,读取中文不正常
1.在系统语言为繁体中文情况下异常,但在系统语言为简体中文情况正常 2.我的vs项目使用的UNIcode字符集 3.下面是我写的代码,但无论如何转字符编码(我有尝试过gb2312 utf8 ansi),变量str都无法正确解析字符串,均为乱码 tinyxml2::XMLDocument doc;
XMLDeclaration* declaration = doc.NewDeclaration();
string text = "白白魂";
//ANSItoUTF8(text);
XMLElement* pRoot = doc.NewElement("Root");
pRoot->SetText(text.c_str());
doc.InsertFirstChild(declaration);
doc.InsertEndChild(pRoot);
doc.SaveFile("C:\\Users\\Method-PC\\Desktop\\1.xml");
tinyxml2::XMLDocument loaddoc;
loaddoc.LoadFile("C:\\Users\\Method-PC\\Desktop\\1.xml");
XMLElement *ele = loaddoc.RootElement();
string str = ele->GetText();
//UTF8toANSI(str);
int a = 0
;