Consider the following program:
public class Test {
public static void main(String[] args){
String s1 = "\u00df";
String s2 = "SS";
System.out.println(s1.toUpperCase().toLowerCase().compareTo(
s2.toUpperCase().toLowerCase()));
System.out.println(s1.compareToIgnoreCase(s2));
}
}
When running it, the following is reported:
J:\>java Test
0
108
I.e. two different results are reported, while the API documentation
states they should be the same.
This is due to the change applied in 1.4 to String.toUpperCase,
which translates a German sharp-s into SS, which is correct, but
invalidates the definition of compareToIgnoreCase().
Note that this is not an issue of compareToIgnoreCase() delivering
satisfactory results or not, but of compying to its specification.
public class Test {
public static void main(String[] args){
String s1 = "\u00df";
String s2 = "SS";
System.out.println(s1.toUpperCase().toLowerCase().compareTo(
s2.toUpperCase().toLowerCase()));
System.out.println(s1.compareToIgnoreCase(s2));
}
}
When running it, the following is reported:
J:\>java Test
0
108
I.e. two different results are reported, while the API documentation
states they should be the same.
This is due to the change applied in 1.4 to String.toUpperCase,
which translates a German sharp-s into SS, which is correct, but
invalidates the definition of compareToIgnoreCase().
Note that this is not an issue of compareToIgnoreCase() delivering
satisfactory results or not, but of compying to its specification.