How to get character by its (unicode) name in Java? I need the reverse of Character.getName(int codePoint)

The ICU4J library can help you here. It has a class UCharacter with getCharFromName and other related methods that can map from various types of character name strings back to the int code points they represent.

However, if you are working with hard coded character names (i.e. quoted string literals in the source code) then it would be far more efficient to do the translation once - use the \u escape in the source code and add a comment with the full name if necessary - rather than incur the cost of parsing the name tables at runtime every time. If the character names are coming from reading a file or similar then obviously you will have to convert at runtime.

Tags:

Java

Unicode