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.
- csr of
-
JDK-4993841 (str) java.lang.Character should have a toString(int) method
-
- Resolved
-