Search code examples
cencodingxml-parsingutfpugixml

PugiXML value output encoding


I am a little confused. pugi::xml_node::value() returns string of type chart_t, which can be either wchar_t or char depends on compilation flags. In documentation to pugiXML said that it works with different types on utf family encodings. OK. I am loading using pugi::xml_document::load_file() a document in uft16 encoding. Then when I am iterating throw nodes and calling value() method on every node, in which encoding I'll get value? Presumably in encoding of my data, which I've loaded to xml_document. This means in utf16. If it in utf16 then I'll can't to work with that value because there will be 0-symbols and I'll can't use strlen, strcpy an so on... I've made such test, but everything works fine. Anybody knows how it works?


Solution

  • http://pugixml.googlecode.com/svn/tags/latest/docs/manual/loading.html

    http://pugixml.googlecode.com/svn/tags/latest/docs/manual/loading.html#manual.loading.encoding

    You can specify encoding by yourself or 'enjoy' auto-detected one.