Mike Ellery wrote:
I'm encoding some data using Base64::encode, which returns me XMLByte*.
Now I want to create a CDATA section using the encoded bytes - the
document's createCDATASection method takes XMLCh*. How do I get to here
from there? Do I need to use XMLString::transcode to get XMLCh?
Apologies if this is covered in the docs - I couldn't find it.
You could use a UTF-8 transcoder, but since the data is guaranteed to be
ASCII-only, you could simply copy each code unit:
unsigned int outputLength = 0;
const XMLByte* const bytes =
Base64::encode(
bytesIn,
bytesInLength,
&outputLength);
XMLCh* wideChars = new XMLCh [outputLength + 1];
for (unsigned int i = 0; i < outputLength; ++i)
{
wideChars[i] = bytes[i];
}
XMLString::release(&bytes);
wideChars[outputLength] = 0;
doc->createCDATASection(wideChars);
delete wideChars;
Dave