Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: How to get Unicode name of a character (or its type category)?

The Character class in Java defines methods which check a given char argument for equality with certain Unicode chars or for belonging to some type category. These chars and type categories are named.

As stated in given javadoc, examples for named chars are
HORIZONTAL TABULATION, FORM FEED, ...;
example for named type categories are
SPACE_SEPARATOR, PARAGRAPH_SEPARATOR, ...

However, being byte or int values instead of enums, the name of these types are "hidden" at runtime.

So, is there a possibility to get characters' and/or type categories' names at runtime?

like image 772
java.is.for.desktop Avatar asked Mar 14 '10 18:03

java.is.for.desktop


People also ask

How do I find the Unicode value of a character?

We can determine the unicode category for a particular character by using the getType() method. It is a static method of Character class and it returns an integer value of char ch representing in unicode general category.

What is the Unicode value of A?

Unicode Character “A” (U+0041)

What is Unicode in Java?

Unicode is a computing industry standard designed to consistently and uniquely encode characters used in written languages throughout the world. The Unicode standard uses hexadecimal to express a character. For example, the value 0x0041 represents the Latin character A.

Does Java have Unicode?

As Java was developed for multilingual languages it adopted the unicode system. So lowest value is represented by \u0000 and highest value is represented by \uFFFF.


1 Answers

JDK7 will have a

String getName(int codepoint)

function (READ: a “static method” in class java.lang.Character) that will turn a codepoint into its official Unicode name.

Javadoc : http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#getName%28int%29

like image 55
tchrist Avatar answered Oct 18 '22 20:10

tchrist