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

(str) java.lang.Character should have a toString(int) method

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 11
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      This is a new method, thus no compatibility issue.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Provide toString() method that takes an int argument in parallel with the existing one that takes a char, in order to support supplementary characters seamlessly.

      Problem

      There's no immediate way to obtain a String from a code point.

      Solution

      Provide an overloaded method to Character.toString()

      Specification

      Add the following method:

      /**
       * Returns a {@code String} object representing the
       * specified character (Unicode code point).  The result is a string of length
       * 1 or 2, consisting solely of the specified {@code codePoint}.
       *
       * @param codePoint the {@code codePoint} to be converted
       * @return the string representation of the specified {@code codePoint}
       * @exception IllegalArgumentException if the specified
       * {@code codePoint} is not a valid Unicode code point.
       * @since 11
       */
       public static String toString(int codePoint)

      Append the following paragraph to the existing toString(char) method description:

         * @apiNote This method cannot handle <a
         * href="#supplementary"> supplementary characters</a>. To support
         * all Unicode characters, including supplementary characters, use
         * the {@link #toString(int)} method.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Reviewed By:
              Alan Bateman, Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: