jinesh kj wrote:
hi,
I have some doubts in this regard. I am having a program which reads the
text content of an XML element by getTextContent and i want to transcode it
to unicode.
String data in Xerces-C is encoded in UTF-16, so it's already Unicode data.
I have a simple doubt out of topic, like can i store the string
in std::string as other non unicode strings and use functions like find and
all?(basically i need to read the string word by word). Also
XMLString::transcode will transcode to native encoding i believe.
Yes, XMLString::transcode() will transcode a string to the local code page,
so it's not very helpful if you care about the fidelity of the data. You
can transcode UTF-16 to UTF-8 and store the UTF-8 bytes in std::string, but
you may not be able to use all of std::string's member functions. There
was a very recent thread on the mailing list about this, so you should
review the recent postings to the list.
If I use a std::wstring, can i solve the problem?
Unlikely, unless your platform support UTF-16 for the wchar_t data type.
Windows is the only platform that does this consistently. Otherwise, you
will probably have to fall back to std::vector<XMLCh>.
Dave