类 HanziToPinyinUtils

java.lang.Object
javabase.lorenwang.tools.common.HanziToPinyinUtils

public class HanziToPinyinUtils
extends Object
An object to convert Chinese character to its corresponding pinyin string. For characters with multiple possible pinyin string, only one is selected according to collator. Polyphone is not supported in this implementation. This class is implemented to achieve the best runtime performance and minimum runtime resources with tolerable sacrifice of accuracy. This implementation highly depends on zh_CN ICU collation data and must be always synchronized with ICU.

Currently this file is aligned to zh.txt in ICU 4.6

  • 字段详细资料

    • UNIHANS

      protected static final char[] UNIHANS
      Unihans array. Each unihans is the first one within same pinyin. Use it to determine pinyin for all ~20k unihans.
    • PINYINS

      protected static final byte[][] PINYINS
      Pinyin array. Each pinyin is corresponding to unihans of same offset in the unihans array.
  • 构造器详细资料

    • HanziToPinyinUtils

      protected HanziToPinyinUtils​(boolean hasChinaCollator)
  • 方法详细资料

    • getInstance

      public static HanziToPinyinUtils getInstance()
    • get

      public ArrayList<HanziToPinyinUtils.Token> get​(String input)
      Convert the input to a array of tokens. The sequence of ASCII or Unknown characters without space will be put into a Token, One Hanzi character which has pinyin will be treated as a Token. If these is no China collator, the empty token array is returned.
      参数:
      input - 输入的文字
      返回:
      返回数据
    • getTokensForDialerSearch

      public String getTokensForDialerSearch​(String input, StringBuilder offsets)