[LANG-1545] CharSequenceUtils.regionMatches is wrong dealing with Georgian. (#529)
* CharSequenceUtils.regionMatches is wrong dealing with Georgian. see details in tests. * refine tests
This commit is contained in:
parent
c0d0d4f3ea
commit
2c7e5e4b29
|
@ -294,9 +294,10 @@ public class CharSequenceUtils {
|
|||
return false;
|
||||
}
|
||||
|
||||
// The same check as in String.regionMatches():
|
||||
if (Character.toUpperCase(c1) != Character.toUpperCase(c2)
|
||||
&& Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
|
||||
// The real same check as in String.regionMatches():
|
||||
char u1 = Character.toUpperCase(c1);
|
||||
char u2 = Character.toUpperCase(c2);
|
||||
if (u1 != u2 && Character.toLowerCase(u1) != Character.toLowerCase(u2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3305,4 +3305,31 @@ public class StringUtilsTest {
|
|||
Locale.setDefault(defaultLocales);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeorgianSample() {
|
||||
char[] arrayI = new char[]{
|
||||
//Latin Small Letter dotless I
|
||||
(char) 0x0131,
|
||||
//Greek Capital Letter Theta
|
||||
(char) 0x03F4
|
||||
};
|
||||
char[] arrayJ = new char[]{
|
||||
//Latin Capital Letter I with dot above
|
||||
(char) 0x0130,
|
||||
//Greek Theta Symbol
|
||||
(char) 0x03D1
|
||||
};
|
||||
for (char i : arrayI) {
|
||||
for (char j : arrayJ) {
|
||||
String si = "" + i;
|
||||
String sj = "" + j;
|
||||
boolean res1 = si.equalsIgnoreCase(sj);
|
||||
CharSequence ci = new StringBuilder(si);
|
||||
CharSequence cj = new StringBuilder(sj);
|
||||
boolean res2 = StringUtils.startsWithIgnoreCase(ci, cj);
|
||||
assertEquals(res1, res2, "si : " + si + " sj : " + sj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue