1.我是用rapidxml文件读取utf-8格式的xml,但是显示乱码。我们需要把读出来的内容转为GBK格式,则能正常显示。
char * utf82gbk(char* strutf)
{
//utf-8转为Unicode
int size = MultiByteToWideChar(CP_UTF8,strutf,-1,NULL,0);WCHAR *strUnicode = new WCHAR[size];
MultiByteToWideChar(CP_UTF8,strUnicode,size);
//Unicode转换成UTF-8;
int i = WideCharToMultiByte(CP_ACP,NULL);char *strGBK = new char[i];
WideCharToMultiByte(CP_ACP,strGBK,i,NULL);
return strGBK;
}
2.使用很简单cout << filepath->name() << ":" << utf82gbk( filepath->value()) << endl;
原文链接:https://www.f2er.com/xml/297244.html