本文整理汇总了Java中com.ibm.icu.lang.UCharacter.getExtendedName方法的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.getExtendedName方法的具体用法?Java UCharacter.getExtendedName怎么用?Java UCharacter.getExtendedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.lang.UCharacter
的用法示例。
在下文中一共展示了UCharacter.getExtendedName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listChars
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Gets a list of code points of valid characters and their names in the given
* font.
*
* @param font
* the source font
* @return a list of code points of valid characters and their names in the
* given font.
* @throws UnsupportedOperationException
* if font does not contain a UCS-4 or UCS-2 cmap
*/
public static DataDisplayTable listChars(Font font) {
String[] header = { "Code point", "Glyph ID", "Unicode-designated name for code point" };
Align[] displayAlignment = { Align.Right, Align.Right, Align.Left };
DataDisplayTable table = new DataDisplayTable(Arrays.asList(header));
table.setAlignment(Arrays.asList(displayAlignment));
// Iterate through all code points
CMap cmap = FontUtils.getUCSCMap(font);
for (int charId : cmap) {
int glyphId = cmap.glyphId(charId);
if (glyphId != CMapTable.NOTDEF) {
String[] data = { FontUtils.getFormattedCodePointString(charId),
String.format("%d", glyphId), UCharacter.getExtendedName(charId) };
table.add(Arrays.asList(data));
}
}
return table;
}
示例2: handleTransliterate
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Implements {@link Transliterator#handleTransliterate}.
*/
@Override
protected void handleTransliterate(Replaceable text,
Position offsets, boolean isIncremental) {
int cursor = offsets.start;
int limit = offsets.limit;
StringBuilder str = new StringBuilder();
str.append(OPEN_DELIM);
int len;
String name;
while (cursor < limit) {
int c = text.char32At(cursor);
if ((name=UCharacter.getExtendedName(c)) != null) {
str.setLength(OPEN_DELIM_LEN);
str.append(name).append(CLOSE_DELIM);
int clen = UTF16.getCharCount(c);
text.replace(cursor, cursor+clen, str.toString());
len = str.length();
cursor += len; // advance cursor by 1 and adjust for new text
limit += len-clen; // change in length
} else {
++cursor;
}
}
offsets.contextLimit += limit - offsets.limit;
offsets.limit = limit;
offsets.start = cursor;
}