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 areHORIZONTAL TABULATION
, FORM FEED
, ...;
example for named type categories areSPACE_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?
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.
Unicode Character “A” (U+0041)
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With