Question

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?

Était-ce utile?

Autres conseils

There are two modes of compilation - the default, where the document stores the in-memory data using UTF8 in char arrays, and the wchar mode (PUGIXML_WCHAR_MODE), where the data is stored in wchar_t arrays using either UTF16 or UTF32, depending on sizeof(wchar_t).

When you are loading or saving the document, pugixml automatically decodes the input data or encodes the output data in the encoding specified by 'encoding' argument for load/save functions.

In your case, pugixml automatically detects that the input file contains UTF16 data and decodes it into UTF8, which is what you get from value().

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top