From 7042fcca3670538a7b2f7e2a33078af01b7c4960 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Fri, 8 Jun 2012 21:53:40 +0000 Subject: [PATCH] ICU-8890 revert error behavior of UnicodeString::replace(start, _length, srcChar) to removing the segment when srcChar is not a valid code point (see r31272) X-SVN-Rev: 31928 --- icu4c/source/common/unistr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/icu4c/source/common/unistr.cpp b/icu4c/source/common/unistr.cpp index 717d092a0ad..3c1292d39df 100644 --- a/icu4c/source/common/unistr.cpp +++ b/icu4c/source/common/unistr.cpp @@ -1249,8 +1249,9 @@ UnicodeString::replace(int32_t start, UBool isError = FALSE; U16_APPEND(buffer, count, U16_MAX_LENGTH, srcChar, isError); // We test isError so that the compiler does not complain that we don't. - // If isError then count==0 which turns the doReplace() into a no-op anyway. - return isError ? *this : doReplace(start, _length, buffer, 0, count); + // If isError (srcChar is not a valid code point) then count==0 which means + // we remove the source segment rather than replacing it with srcChar. + return doReplace(start, _length, buffer, 0, isError ? 0 : count); } UnicodeString& -- 2.40.0