DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7022>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7022 DOMString::transcode ( and XMLString::transcode() ) fails on SuSE LINUX 7.3 for non UTF-8 Strings ------- Additional Comments From [EMAIL PROTECTED] 2002-03-13 14:37 ------- I think that you may be confused about the role of XMLString::transcode() - which is not hard, especially since the documentation is a little sparse in this area. Someone with more knowledge of the whole transcoding issue should really write a little primer so that we can put it in the docs. Anyway... transcode() is designed to take Xerces internal UTF-16 representation of the data (using only data in your local code page) and return it as a char * array (still in your local code page) and vica versa. It only deals with data in your local code page. If you are getting data with real unicode characters you proabably want to create your own transcoder object. Here's an example of how to do that taken from the Xerces-Perl distro: // we initialize the static UTF-8 transcoding info // these are used by the typemaps to convert between // Xerces internal UTF-16 and Perl's internal UTF-8 static XMLCh* UTF8_ENCODING = NULL; static XMLTranscoder* UTF8_TRANSCODER = NULL; // we create the global transcoder for UTF-8 to UTF-16 XMLTransService::Codes failReason; XMLPlatformUtils::Initialize(); // first we must create the transservice UTF8_ENCODING = XMLString::transcode("UTF-8"); UTF8_TRANSCODER = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(UTF8_ENCODING, failReason, 1024); if (! UTF8_TRANSCODER) { croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder"); } and here's an example of how to use it to transcode a string in UTF-8 into UTF-16 so that Xerces can handle it: unsigned int charsEaten = 0; unsigned char* sizes = new unsigned char[length+1]; arg5 = new XMLCh[length+1]; unsigned int chars_stored = UTF8_TRANSCODER->transcodeFrom((const XMLByte*) ptr, (unsigned int) length, (XMLCh*) arg5, (unsigned int) length, charsEaten, (unsigned char*)sizes ); delete [] sizes; And here's an example of going to UTF-16 into UTF-8: unsigned int charsEaten = 0; int length = XMLString::stringLen(result); // string length XMLByte* res = new XMLByte[length * UTF8_MAXLEN]; // output string unsigned int total_chars = UTF8_TRANSCODER->transcodeTo((const XMLCh*) result, (unsigned int) length, (XMLByte*) res, (unsigned int) length*UTF8_MAXLEN, charsEaten, XMLTranscoder::UnRep_Throw ); res[total_chars] = '\0'; Hope this helps, jas. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
