From 3e2461f0926d93561b4217eaa7a9dec3e313b838 Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Mon, 26 Nov 2001 18:09:31 +0000
Subject: [PATCH] Starting ICU 2.0, all ICU String functions have consistent
 NUL-termination behavior.  The returned length is always the number of output
 UChar's, not counting an additional, terminating Null.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173303 13f79535-47bb-0310-9956-ffa450edef68
---
 src/util/Transcoders/ICU/ICUTransService.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util/Transcoders/ICU/ICUTransService.cpp b/src/util/Transcoders/ICU/ICUTransService.cpp
index f365b9aa9..4b40a2ba5 100644
--- a/src/util/Transcoders/ICU/ICUTransService.cpp
+++ b/src/util/Transcoders/ICU/ICUTransService.cpp
@@ -791,8 +791,14 @@ unsigned int ICULCPTranscoder::calcRequiredSize(const char* const srcText)
     if (err != U_BUFFER_OVERFLOW_ERROR)
         return 0;
 
+#if (U_ICU_VERSION_MAJOR_NUM < 2)
     // Subtract one since it includes the terminator space
     return (unsigned int)(targetCap - 1);
+#else
+    // Starting ICU 2.0, this is fixed and all ICU String functions have consistent NUL-termination behavior.
+    // The returned length is always the number of output UChar's, not counting an additional, terminating NUL.
+    return (unsigned int)(targetCap);
+#endif
 }
 
 
-- 
GitLab