diff --git a/src/util/Transcoders/ICU/ICUTransService.cpp b/src/util/Transcoders/ICU/ICUTransService.cpp index 185c74a0c0ef48d9fd83b53f198afade27934c7c..55b1052a48f8d969eb88eb335a196b5bc7df4258 100644 --- a/src/util/Transcoders/ICU/ICUTransService.cpp +++ b/src/util/Transcoders/ICU/ICUTransService.cpp @@ -467,14 +467,19 @@ ICUTranscoder::transcodeFrom(const XMLByte* const srcData } else { - // <TBD> Does ICU return an extra element to allow us to figure - // out the last char size? It better!! + // ICU does not return an extra element to allow us to figure + // out the last char size, so we have to compute it from the + // total bytes used. unsigned int index; - for (index = 0; index < charsDecoded; index++) + for (index = 0; index < charsDecoded - 1; index++) { charSizes[index] = (unsigned char)(fSrcOffsets[index + 1] - fSrcOffsets[index]); } + if( charsDecoded > 0 ) { + charSizes[charsDecoded - 1] = (unsigned char)(bytesEaten + - fSrcOffsets[charsDecoded - 1]); + } } } diff --git a/src/util/Transcoders/Iconv400/Iconv400TransService.cpp b/src/util/Transcoders/Iconv400/Iconv400TransService.cpp index cbee1f7bae3815f779ae8cf1145075386d42ca96..c5ee784da5410024a5298cb773ee63fec0e0dcf0 100644 --- a/src/util/Transcoders/Iconv400/Iconv400TransService.cpp +++ b/src/util/Transcoders/Iconv400/Iconv400TransService.cpp @@ -428,14 +428,19 @@ Iconv400Transcoder::transcodeXML(const XMLByte* const srcData } else { - // <TBD> Does Iconv return an extra element to allow us to figure - // out the last char size? It better!! + // ICU does not return an extra element to allow us to figure + // out the last char size, so we have to compute it from the + // total bytes used. unsigned int index; - for (index = 0; index < charsDecoded; index++) + for (index = 0; index < charsDecoded - 1; index++) { charSizes[index] = (unsigned char)(fSrcOffsets[index + 1] - fSrcOffsets[index]); } + if( charsDecoded > 0 ) { + charSizes[charsDecoded - 1] = (unsigned char)(bytesEaten + - fSrcOffsets[charsDecoded - 1]); + } } } @@ -543,14 +548,19 @@ Iconv400Transcoder::transcodeFrom(const XMLByte* const srcData } else { - // <TBD> Does ICU return an extra element to allow us to figure - // out the last char size? It better!! + // ICU does not return an extra element to allow us to figure + // out the last char size, so we have to compute it from the + // total bytes used. unsigned int index; - for (index = 0; index < charsDecoded; index++) + for (index = 0; index < charsDecoded - 1; index++) { charSizes[index] = (unsigned char)(fSrcOffsets[index + 1] - fSrcOffsets[index]); } + if( charsDecoded > 0 ) { + charSizes[charsDecoded - 1] = (unsigned char)(bytesEaten + - fSrcOffsets[charsDecoded - 1]); + } } }