tinyxml2 icon indicating copy to clipboard operation
tinyxml2 copied to clipboard

在系统语言为繁体中文情况下,读取中文不正常

Open MethodJiao opened this issue 3 years ago • 0 comments

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

企业微信截图_20220810160112 ;

MethodJiao avatar Aug 10 '22 08:08 MethodJiao