Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ public static boolean regionMatches(
}

// The same check as in String.regionMatches():
if (Character.toUpperCase(c1) != Character.toUpperCase(c2)
&& Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
final char upper1 = Character.toUpperCase(c1);
final char upper2 = Character.toUpperCase(c2);
if (upper1 != upper2 && Character.toLowerCase(upper1) != Character.toLowerCase(upper2)) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,28 @@ boolean invoke() {
}
}

@Test
void test_regionMatches_unicodeIgnoreCase() {
final CharSequence[] dottedI = {"İ", new StringBuilder("İ")};
final CharSequence[] dotlessI = {"ı", new StringBuilder("ı")};
for (final CharSequence source : dottedI) {
for (final CharSequence other : dotlessI) {
Assertions.assertEquals(
source.toString().regionMatches(true, 0, other.toString(), 0, 1),
StringUtils.regionMatches(source, true, 0, other, 0, 1));
Assertions.assertEquals(
other.toString().regionMatches(true, 0, source.toString(), 0, 1),
StringUtils.regionMatches(other, true, 0, source, 0, 1));
Assertions.assertEquals(
source.toString().regionMatches(false, 0, other.toString(), 0, 1),
StringUtils.regionMatches(source, false, 0, other, 0, 1));
Assertions.assertEquals(
other.toString().regionMatches(false, 0, source.toString(), 0, 1),
StringUtils.regionMatches(other, false, 0, source, 0, 1));
}
}
}

@Test
void stripTest() {
Assertions.assertNull(StringUtils.strip(null));
Expand Down