--- old/src/java.base/share/classes/java/lang/Character.java 2016-02-03 09:21:10.917226349 -0800 +++ new/src/java.base/share/classes/java/lang/Character.java 2016-02-03 09:21:10.693227349 -0800 @@ -10145,7 +10145,7 @@ if (!isValidCodePoint(codePoint)) { throw new IllegalArgumentException(); } - String name = CharacterName.get(codePoint); + String name = CharacterName.getInstance().getName(codePoint); if (name != null) return name; if (getType(codePoint) == UNASSIGNED) @@ -10157,4 +10157,47 @@ // should never come here return Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH); } + + /** + * Returns the code point value of the Unicode character specified by + * the given Unicode character name. + *

+ * Note: if a character is not assigned a name by the UnicodeData + * file (part of the Unicode Character Database maintained by the Unicode + * Consortium), its name is defined as the result of expression + * + *

{@code + * Character.UnicodeBlock.of(codePoint).toString().replace('_', ' ') + * + " " + * + Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH); + * + * }
+ *

+ * The {@code name} matching is case insensitive, with any leading and + * trailing whitespace character removed. + * + * @param name the Unicode character name + * + * @return the code point value of the character specified by its name. + * + * @exception IllegalArgumentException if the specified {@code name} + * is not a valid Unicode character name. + * + * @since 9 + */ + public static int codePointOf(String name) { + name = name.trim().toUpperCase(Locale.ENGLISH); + int cp = CharacterName.getInstance().getCodePoint(name); + if (cp != -1) + return cp; + try { + int off = name.lastIndexOf(' '); + if (off != -1) { + cp = Integer.parseInt(name, off + 1, name.length(), 16); + if (isValidCodePoint(cp) && name.equals(getName(cp))) + return cp; + } + } catch (Exception x) {} + throw new IllegalArgumentException("Unrecognized character name :" + name); + } }