2010/11/29 Stanisław Findeisen <[email protected]> > Hi Ganesh > > > On 11/29/2010 02:45 PM, Ganesh Pagade wrote: > >> I have a C++ string which is in UTF-8, which I am passing to >> XMLString::transcode(). However XMLString::transcode() is expecting SJIS >> (Japanese). So it returns garbage characters in XMLCh*. >> > > Which of the XMLString::transcode methods are you calling? > > I think this one: > http://xerces.apache.org/xerces-c/apiDocs-2/classXMLString.html#392a86c9a310dff366bedf2330050c3bhas > a buggy description (shouldn't it read: "Transcodes a string *from* > native code-page"??) and the expected input string format is platform > dependent.
Thanks STF for the reply. Yes that's the one I am using. > > > So I tired using XMLUTF8Transcoder. However XMLUTF8Transcoder's >> transcodeTo() >> expects XMLCh*. >> >> How do I convert C++ string into XMLCh* without using the >> XMLString::transcode(), >> so that I can pass it to transcodeTo()? >> >> Or how do I make XMLString::transcode() expect UTF-8? >> >> Any suggestions/pointers would be highly appreciated. >> > > People on this list have told me (Sat, 24 Jul 2010 10:48:38 -0700) that > XMLCh is UTF-16 with platform byte order. So converting char* to XMLCh* > equals converting char* to UTF-16 (with platform byte order). You should be > able to do it with iconv (which is POSIX.1-2001 conforming) or, if you need > any more sophisticated string operations, you might want to use ICU: > http://userguide.icu-project.org/strings . > I believe you are suggesting me to use the Iconv transcoder (which is present in include\xercesc\util\Transcoders\Iconv). I tired following code: IconvLCPTranscoder *trans = new IconvLCPTranscoder(); xmlTransCodeTemp = trans->transcode(pathName.c_str()); // pathName is my C++ string, UTF-8 containing Japanese characters. However this gives me xmlTransCodeTemp as null. Am I doing something wrong here or I misunderstood? BTW, I am using Xerces 2.8 and working on Windows x64 with Visual Studio 2005. STF >
