I don’t seem to understand the purpose of XMLString::transcode(XMLCh*) and XMLString::transcode(char*) , because obviously I don’t understand the difference between XMLCh* and char*.
Can someone please make things clearer for me ?
I don’t seem to understand the purpose of XMLString::transcode(XMLCh*) and XMLString::transcode(char*) , because obviously
Share
Xerces encodes information as UTF-16 internally. The UTF-16 data is stored using the
XMLChdatatype.‘C-style’ strings use
charwhich is in the local code page (probably UTF-8, but it depends on the platform and settings) You usetranscodeto convert between the two.For instance if you want to feed some data from Xerces to another library and that library expects text in the local code page, you need to
transcodeit. Also, if you havechardata and want to feed it to Xerces, you need totranscodeit toXMLCh, because that is what Xerces understands.For example:
Do not forget to release the string! Better is to write some wrapper round it but there are examples available on the internet (just search for a class named
XercesString).If you want to know more about encodings I think you should read The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)