diff --git a/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp b/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp
index 63f0fe45f63a8f97723aafae8911be548172643e..9b3b8be165131d4bc27e7d2e721a458c1b071ac8 100644
--- a/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp
+++ b/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp
@@ -907,7 +907,7 @@ char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode)
     }
 
     // If targetLen is not enough then buffer overflow might occur
-    if (err == U_BUFFER_OVERFLOW_ERROR)
+    if ((err == U_BUFFER_OVERFLOW_ERROR) || (err == U_STRING_NOT_TERMINATED_WARNING))
     {
         //
         //  Reset the error, delete the old buffer, allocate a new one,
@@ -936,8 +936,6 @@ char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode)
         return 0;
     }
 
-    // Cap it off and return
-    retBuf[targetCap] = 0;
     return retBuf;
 }
 
@@ -1010,7 +1008,7 @@ char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode,
     }
 
     // If targetLen is not enough then buffer overflow might occur
-    if (err == U_BUFFER_OVERFLOW_ERROR)
+    if ((err == U_BUFFER_OVERFLOW_ERROR) || (err == U_STRING_NOT_TERMINATED_WARNING))
     {
         //
         //  Reset the error, delete the old buffer, allocate a new one,
@@ -1039,8 +1037,6 @@ char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode,
         return 0;
     }
 
-    // Cap it off and return
-    retBuf[targetCap] = 0;
     return retBuf;
 }