Today i download the "tinyxml_2_3_2.zip". And add it to my project. Then i write some attributes which values are simple chinese to a xml file. When i open the xml file by IE. it tell me there are something wrong. All the chinese word become to chaos code. I can't read it again.
But if i use the notepad open the xml file. it looks normally.
Who can tell me how can i use the tinyxml write some simple chinese as a attribute, and open it in IE?
Thanks!
kazikong(kazi@eyou.com)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your reply. But the problem still exist.
I'll describe it detailedly.
The following is the test code:
//Begin////////////////////////////////////////////////////
#include <string>
#include "../../tinyxml/tinyxml.h"
using namespace std;
void main()
{
TiXmlDocument td("TaskLogTemplate.xml");
std::string ss("测试字符");
TiXmlDeclaration decl("1.0", "UTF-8", "no");
TiXmlElement item("Player");
item.SetAttribute("Account", ss.c_str());
td.InsertEndChild(decl);
td.InsertEndChild(item);
td.SaveFile();
}
//End////////////////////////////////////////////////////
The result is :
//Begin////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Player Account="�����ַ" />
//End////////////////////////////////////////////////////
The value of Account are messy characters, i don't know why. But if i use the fstream in the STL to write the same simplified Chinese characters, all goes right.
I followed your recommend to use the JEdit to open the xml file, it shows space character at the place of value.
My Operating System is Windows XP Professional SP2 simplified Chinese Version.
Can you tell me how to use tinyxml deal with some simplified Chinese characters?
Thank you very much!
kazi(kazi@eyou.com)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Today i download the "tinyxml_2_3_2.zip". And add it to my project. Then i write some attributes which values are simple chinese to a xml file. When i open the xml file by IE. it tell me there are something wrong. All the chinese word become to chaos code. I can't read it again.
But if i use the notepad open the xml file. it looks normally.
Who can tell me how can i use the tinyxml write some simple chinese as a attribute, and open it in IE?
Thanks!
kazikong(kazi@eyou.com)
From your post this has nothing to do with TinyXml. It is just an XML thing.
Could it be that you have mismatched the encoding type declared in the xml itself and the actual file format you save in?
For example: <?xml encoding="utf8">
but you haved it in some other encoding?
I can recommend JEdit as a good text editor for seeing/managing the actual encoding that a file is in, though I haven't tried it with Chinese.
Hope that helps...
Thank you for your reply. But the problem still exist.
I'll describe it detailedly.
The following is the test code:
//Begin////////////////////////////////////////////////////
#include <string>
#include "../../tinyxml/tinyxml.h"
using namespace std;
void main()
{
TiXmlDocument td("TaskLogTemplate.xml");
std::string ss("测试字符");
TiXmlDeclaration decl("1.0", "UTF-8", "no");
TiXmlElement item("Player");
item.SetAttribute("Account", ss.c_str());
td.InsertEndChild(decl);
td.InsertEndChild(item);
td.SaveFile();
}
//End////////////////////////////////////////////////////
The result is :
//Begin////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Player Account="�����ַ" />
//End////////////////////////////////////////////////////
The value of Account are messy characters, i don't know why. But if i use the fstream in the STL to write the same simplified Chinese characters, all goes right.
I followed your recommend to use the JEdit to open the xml file, it shows space character at the place of value.
My Operating System is Windows XP Professional SP2 simplified Chinese Version.
Can you tell me how to use tinyxml deal with some simplified Chinese characters?
Thank you very much!
kazi(kazi@eyou.com)
Thread continued:
https://sourceforge.net/forum/message.php?msg_id=2730468