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 "Alberto Massari (JIRA)" <xe...@xml.apache.org> on 2004/12/29 22:50:05 UTC
[jira] Resolved: (XERCESC-1300) XMLString::transocde() => ICULCPTranscoder::transcode not terminating string
[ http://nagoya.apache.org/jira/browse/XERCESC-1300?page=history ]
Alberto Massari resolved XERCESC-1300:
--------------------------------------
Resolution: Fixed
You are right, if ICU finds the buffer too small it returns the length of the converted string (excluding the NULL terminator); but ucnv_fromUChars wants the size of the target buffer, including the space for the NULL.
The fix is in CVS. Please verify.
Alberto
> 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: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org