You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Max Winther <ma...@wanadoo.dk> on 2003/12/08 09:34:42 UTC
XMLCh and std::wstrng (UCS-4) on Solaris
Hi
I am doing a project with xerces-c on a Sun Solaris UNIX - platform using the std::wstring, which is UCS-4 encoded. I have read a lot and searched around the net a lot. Can somebody please tell my an easier way to convert my std::wstring's into XMLCh than enlarging the XStr, taken directly form the sample CreateDomDucemnt, with the following constructor:
XStr(const std::wstring& toTransCOde)
{
// construct a transcoder in UCS-4, do it static to reuse the transcoder
XMLTransService::Codes resCode(XMLTransService::Ok);
static XMLTranscoder* aUCS4Transcoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor("ucs4",
resCode,
4*1024);
if (resCode != XMLTransService::Ok || aUCS4Transcoder == null)
{
//TODO handle error and return
}
unsigned int charsEaten;
unsigned int srcCount = toTransCode.size();
unsigned int maxChars = toTransCode.size();
char[] charSizes[toTransCode.size()];
//Construct a stack XMLCh, did not find a way to construct a heap XMLCh like XMLString::transcode(const char*)
XMLCh localXMLCh[toTransCode.size() + 1];
aUCS4Transcoder->transcodeFrom((XMLByte)toTransCode.c_str(),
srcCount,
&localXMLCh,
maxChars,
&charsEaten,
&charSizes);
//TODO Handle Errors: using charsEaten
//Move the local stack XMLCh into the heap
fUnicodeForm = XMLString::replicate(localfUnicodeForm);
}
regards
Max Winther
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org