From: Markus Scherer Date: Fri, 8 Jun 2012 21:53:40 +0000 (+0000) Subject: ICU-8890 revert error behavior of UnicodeString::replace(start, _length, srcChar... X-Git-Tag: milestone-59-0-1~3776 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7042fcca3670538a7b2f7e2a33078af01b7c4960;p=icu 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 --- 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&