Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4120540

string1.equalsIgnoreCase(string2) differs from string1.toUpperCase().equals(stri

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.2.0
    • core-libs
    • generic
    • solaris_2.5.1


      A German licensee has reported problems with our handling of the small sharp s (\u00DF) in our String class. In particular the equalsIgnoreCase method doesn't handle this character.

      Here is an example to duplicate the problem :-

      class test {
          public static void main(String[] args) {

              String string1 = "abc\u00DF";
              String string2 = string1.toUpperCase();

              if (string1.equalsIgnoreCase(string2))
                  System.out.println("equalsIgnoreCase says they are equal");

              if (string1.toUpperCase().equals(string2.toUpperCase()))
                  System.out.println("equals says they are equal");


          }
      }

      The issue is that toUpperCase converts \00DF to SS but this is not taken into account by the internal regionMatches method.




            mmcclosksunw Michael Mccloskey (Inactive)
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: