my first question here :-)
Did my best reading the rules and searching if the question was already asked before.
The following code
    String[] strings = {"cAsE", "\u00df"};
    for (String str : strings) {
        System.out.println(str.equalsIgnoreCase(str.toLowerCase()));
        System.out.println(str.equalsIgnoreCase(str.toUpperCase()));
    }
outputs true 3 times (cAsE = case; cAsE = CASE; ß = ß) but also 1 false (ß != SS). Tried using toLowerCase(Locale) but it did't help.
Is this a known issue?
Until recently, Unicode didn't define an uppercase version of s-sharp. I'm not sure whether the latest Java 7 version does already include this new character and whether it handles it correctly. I suggest to give it a try.
The reason why str.toLowerCase() doesn't return the same as str.toUpperCase().toLowerCase() is that Java replaces ß with SS but there is no way to go back, so SS becomes ss and the compare fails.
So if you need to level the case, you must use str.toLowerCase(). If not, then simply calling equalsIgnoreCase() without any upper/lower conversion should work, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With