Java:如何获取字符的Unicode名称(或其类型类别)? [英] Java: How to get Unicode name of a character (or its type category)?
问题描述
Character
中的类定义了检查给定的 char
参数是否与某些Unicode字符相等或属于一些类型类别。
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.
如给定的javadoc中所述,命名字符的示例为
HORIZONTAL TABULATION
, FORM FEED
,...;
命名类型类别的示例为
SPACE_SEPARATOR
, PARAGRAPH_SEPARATOR
,...
As stated in given javadoc, examples for named chars are
HORIZONTAL TABULATION
, FORM FEED
, ...;
example for named type categories are
SPACE_SEPARATOR
, PARAGRAPH_SEPARATOR
, ...
c $ c> byte 或 int
而不是枚举,这些类型的名称在运行时被隐藏。
However, being byte
or int
values instead of enums, the name of these types are "hidden" at runtime.
因此,是否有可能在运行时获取字符和/或类型类型的名称?
推荐答案
JDK7将有一个
String getName(int codepoint)
函数(阅读:类java.lang.Character中的静态方法)将代码点转换为其官方Unicode
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
这篇关于Java:如何获取字符的Unicode名称(或其类型类别)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!