ICU-9774 FilteredNormalizer2: CharSequence.subSequence(start, limit) limit must be <= length()
X-SVN-Rev: 32911
This commit is contained in:
parent
95098e216b
commit
64cb025065
@ -277,7 +277,8 @@ public class FilteredNormalizer2 extends Normalizer2 {
|
||||
norm2.append(first, prefix);
|
||||
}
|
||||
} else {
|
||||
StringBuilder middle=new StringBuilder(first.subSequence(suffixStart, 0x7fffffff));
|
||||
StringBuilder middle=new StringBuilder(
|
||||
first.subSequence(suffixStart, first.length()));
|
||||
if(doNormalize) {
|
||||
norm2.normalizeSecondAndAppend(middle, prefix);
|
||||
} else {
|
||||
@ -287,7 +288,7 @@ public class FilteredNormalizer2 extends Normalizer2 {
|
||||
}
|
||||
}
|
||||
if(prefixLimit<second.length()) {
|
||||
CharSequence rest=second.subSequence(prefixLimit, 0x7fffffff);
|
||||
CharSequence rest=second.subSequence(prefixLimit, second.length());
|
||||
if(doNormalize) {
|
||||
normalize(rest, first, UnicodeSet.SpanCondition.NOT_CONTAINED);
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and
|
||||
* Copyright (C) 1996-2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -2651,6 +2651,26 @@ public class BasicTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
|
||||
public void TestFilteredAppend() {
|
||||
Normalizer2 nfcNorm2=Normalizer2.getNFCInstance();
|
||||
UnicodeSet filter=new UnicodeSet("[^\u00a0-\u00ff\u0310-\u031f]");
|
||||
FilteredNormalizer2 fn2=new FilteredNormalizer2(nfcNorm2, filter);
|
||||
|
||||
// Append two strings that each contain a character outside the filter set.
|
||||
StringBuilder sb = new StringBuilder("a\u0313a");
|
||||
String second = "\u0301\u0313";
|
||||
assertEquals("append()", "a\u0313á\u0313", fn2.append(sb, second).toString());
|
||||
|
||||
// Same, and also normalize the second string.
|
||||
sb.replace(0, 0x7fffffff, "a\u0313a");
|
||||
assertEquals(
|
||||
"normalizeSecondAndAppend()",
|
||||
"a\u0313á\u0313", fn2.normalizeSecondAndAppend(sb, second).toString());
|
||||
|
||||
// Normalizer2.normalize(String) uses spanQuickCheckYes() and normalizeSecondAndAppend().
|
||||
assertEquals("normalize()", "a\u0313á\u0313", fn2.normalize("a\u0313a\u0301\u0313"));
|
||||
}
|
||||
|
||||
public void TestGetEasyToUseInstance() {
|
||||
// Test input string:
|
||||
// U+00A0 -> <noBreak> 0020
|
||||
|
Loading…
Reference in New Issue
Block a user