xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Bertoni <dbert...@apache.org>
Subject Re: XMLString Class and ordinary C-strings
Date Thu, 30 Jul 2009 17:35:38 GMT
BRM wrote:
> See XMLString::transcode(). Works boths ways. Just remember to use XMLString::release()
as well.
> 
> char* myCString = "some string";
> XMLCh* myXMLString = XMLString::transcode(myCString);
> // use it
> ...
> if (myXMLString != NULL) XMLString::release(&myXMLString);
> 
> or
> 
> ...
> const XMLCh* myXMLString = someNode->getTagName();
> char* myCString = XMLString::transcode(myXMLString);
> 
> // use it
> ...
> if (myCString != NULL) XMLString::release(&myCString);
Using XMLString::transcode() is dangerous when you don't know if the 
strings you're transcoding are compatible with the local code page. The 
safest approach is to use UTF-8, since it can represent all Unicode 
characters.

Dave

Mime
View raw message