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

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

XMLWordPrintable

    • b04

      Name: gm110360 Date: 02/12/2004


      A DESCRIPTION OF THE REQUEST :
      In 1.5, Unicode supplemental character support is added. In most cases this is by providing additional methods that take an int argument to handle Unicode code points. There are even utility methods to convert a code point to a char[] and so on. However, the toString method of Character only has the default and char methods. Shouldn't there be one that converts a Unicode code point (an int) to a String (which might contain a surrogate pair)?

      JUSTIFICATION :
      Although it is only one line of code to contruct a String from a char[], sometimes this is inconvenient. Heck, it just seems like an oversight. Maybe there's a good reason not to provide this method, but I can't think of one offhand. (Neither can I think of a particularly compelling reason for it either....)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      New method Character.toString(int) returns the string representation of the character represented by the code point...

          public String toString(int codepoint) {
              return new String(Character.toChars(codepoint);
           }
      ACTUAL -
      This is an RFE.
      (Incident Review ID: 238409)
      ======================================================================

            naoto Naoto Sato
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: