当前位置: 首页>>代码示例>>Java>>正文


Java UCharacter.getExtendedName方法代码示例

本文整理汇总了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;
}
 
开发者ID:terro,项目名称:WCFont,代码行数:31,代码来源:FontInfo.java

示例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;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:36,代码来源:UnicodeNameTransliterator.java


注:本文中的com.ibm.icu.lang.UCharacter.getExtendedName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。