return *this;
}
}
- bi->setText(*this);
+ // Because the "this" string is both the source and the destination,
+ // make a copy of the original source for use by the break iterator.
+ // See tickets #13127 and #13128
+ UnicodeString copyOfInput(*this);
+ bi->setText(copyOfInput);
caseMap(ustrcase_getCaseLocale(locale.getBaseName()), options, bi, ustrcase_internalToTitle);
if(titleIter==NULL) {
delete bi;
void TestCaseMapWithEdits();
void TestCaseMapUTF8WithEdits();
void TestLongUnicodeString();
+ void TestBug13127();
private:
void assertGreekUpper(const char16_t *s, const char16_t *expected);
TESTCASE_AUTO(TestCaseConversion);
#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
TESTCASE_AUTO(TestCasing);
+ TESTCASE_AUTO(TestBug13127);
#endif
TESTCASE_AUTO(TestFullCaseFoldingIterator);
TESTCASE_AUTO(TestGreekUpper);
s.toUpper(Locale::getRoot());
assertEquals("string length 306", expected, s);
}
+
+void StringCaseTest::TestBug13127() {
+ // Test case crashed when the bug was present.
+ const char16_t *s16 = u"日本語";
+ UnicodeString s(TRUE, s16, -1);
+ s.toTitle(0, Locale::getEnglish());
+}