]> granicus.if.org Git - icu/commitdiff
ICU-8890 revert error behavior of UnicodeString::replace(start, _length, srcChar...
authorMarkus Scherer <markus.icu@gmail.com>
Fri, 8 Jun 2012 21:53:40 +0000 (21:53 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Fri, 8 Jun 2012 21:53:40 +0000 (21:53 +0000)
X-SVN-Rev: 31928

icu4c/source/common/unistr.cpp

index 717d092a0ad538ae30ef51d3065204768f4f638d..3c1292d39df61e1d8c246fbd46706a76aa3fec24 100644 (file)
@@ -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&