XMLString::transocde() => ICULCPTranscoder::transcode not terminating string ----------------------------------------------------------------------------
Key: XERCESC-1300 URL: http://nagoya.apache.org/jira/browse/XERCESC-1300 Project: Xerces-C++ Type: Bug Components: Utilities Versions: 2.5.0, 2.6.0 Environment: Win32, default codepage was "windows-936-2000", Xerces 2.5 with ICU 2.8 Reporter: Scott Case Priority: Minor Sometimes data doesn't get null terminated when transcoding Chinese characters from UTF-16 to windows-936-2000 via "char *XMLString::trancode(XMLCh*)". What appears to happen is that once the call gets into the function: "char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode)" the amount of memory allocated is too small and the first attempt to ucnv_fromUChars() fails after which the buffer is enlarged and the transcoding is attempted again. This second call to ucnv_fromUChars() returns U_STRING_NOT_TERMINATED_WARNING which is not an error so the overall function succeeds but leaves the data unterminated. The fix is to modify the second call to ucnv_fromUChars as shown below: ucnv_fromUChars(fConverter,retBuf , targetCap // Change to: targetCap +1 , actualSrc, -1, &err); A workaround is to use "bool XMLString::transcode(const XMLCh *const toTranscode, char *const toFill, const unsigned int maxChars)" which doesn't exhibit this problem. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://nagoya.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]