Menu

Why can't i write simple chinese by tinyxml?

kazi
2004-08-21
2004-08-26
  • kazi

    kazi - 2004-08-21

    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)

     
    • Ellers

      Ellers - 2004-08-21

      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...

       
    • kazi

      kazi - 2004-08-26

      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("&#27979;&#35797;&#23383;&#31526;");
          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="&#65533;&#65533;&#65533;&#65533;&#65533;&#1463;" />
      //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)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.