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

Support supplementary characters in String case insensitive operations

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • None
    • core-libs
    • b08
    • generic
    • generic

      The issue JDK-8248434 revealed that the case-insensitive comparisons for supplementary characters in the following methods have problems:

      java.lang.String.regionMatches(ignoreCase == true, ...)
      java.lang.String.equalsIgnoreCase()
      java.lang.String.compareToIgnoreCase()

      These methods are supposed to match/compare strings in a case-insensitive manner. However, their specs and implementations are char based, which cannot handle supplementary characters correctly. For example,

      "\ud83a\udd2e".regionMatches(true, 0, "\ud83a\udd0c", 0, 2)
      Returns false (conforming to the existing spec), although "\ud83a\udd2e" is the 'ADLAM SMALL LETTER O' character which has the code point U+1E92E, and "\ud83a\udd0c" is the 'ADLAM CAPITAL LETTER O' character which has the code point U+1E90C. Thus it should return true if it is true to the meaning of "ignore case." This behavior contradicts to the fact that:

      "\ud83a\udd2e".toUpperCase(Locale.ROOT).equals("\ud83a\udd0c")
      Character.toUpperCase(0x1e92e) == 0x1e90c
      each statement returns true.

      Both the spec and its implementation need to be modified.

        There are no Sub-Tasks for this issue.

            naoto Naoto Sato
            naoto Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: