Package net.sourceforge.pinyin4j.format

Examples of net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat


        this.spell = spell;
    }

    public void execute() {
        // 拼音
        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
        format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        format.setVCharType(HanyuPinyinVCharType.WITH_V);

        char[] chars = name.toCharArray();

        for (char c : chars) {
            String s = Character.toString(c);
View Full Code Here


  String separator) {

    // 创建汉语拼音处理类

    HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();

    // 输出设置,大小写,音标方式

    defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);

    defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);

    StringBuffer tempPinying = new StringBuffer();

    // 如果是中文
View Full Code Here

  @SuppressWarnings("deprecation")
  public static String hanziToPinyin(String hanzi, String separator) {

    // 创建汉语拼音处理类

    HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();

    // 输出设置,大小写,音标方式

    defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);

    defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);

    String pinyingStr = "";

    try {
View Full Code Here

    t1 = src.toCharArray();
    // org.jeecgframework.core.util.LogUtil.info(t1.length);
    String[] t2 = new String[t1.length];
    // org.jeecgframework.core.util.LogUtil.info(t2.length);
    // 设置汉字拼音输出的格式
    HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat();
    t3.setCaseType(HanyuPinyinCaseType.LOWERCASE);
    t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
    t3.setVCharType(HanyuPinyinVCharType.WITH_V);
    String t4 = "";
    int t0 = t1.length;
    try {
      for (int i = 0; i < t0; i++) {
        // 判断能否为汉字字符
View Full Code Here

   * @return 拼音
   */
  public static String converterToFirstSpell(String chines) {
    String pinyinName = "";
    char[] nameChar = chines.toCharArray();
    HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
    defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
    defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
    for (int i = 0; i < nameChar.length; i++) {
      if (nameChar[i] > 128) {
        try {
          pinyinName += PinyinHelper.toHanyuPinyinStringArray(
              nameChar[i], defaultFormat)[0].charAt(0);
View Full Code Here

   * @return 拼音
   */
  public static String converterToSpell(String chines) {
    String pinyinName = "";
    char[] nameChar = chines.toCharArray();
    HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
    defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
    defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
    for (int i = 0; i < nameChar.length; i++) {
      if (nameChar[i] > 128) {
        try {
          pinyinName += PinyinHelper.toHanyuPinyinStringArray(
              nameChar[i], defaultFormat)[0];
View Full Code Here

  public static Set<String> getPinyin(String src) {
    if (src != null && !src.trim().equalsIgnoreCase("")) {
      char[] srcChar;
      srcChar = src.toCharArray();
      // 汉语拼音格式输出类
      HanyuPinyinOutputFormat hanYuPinOutputFormat = new HanyuPinyinOutputFormat();

      // 输出设置,大小写,音标方式等
      hanYuPinOutputFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
      hanYuPinOutputFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
      hanYuPinOutputFormat.setVCharType(HanyuPinyinVCharType.WITH_V);

      String[][] temp = new String[src.length()][];
      for (int i = 0; i < srcChar.length; i++) {
        char c = srcChar[i];
        // 是中文或者a-z或者A-Z转换拼音(我的需求,是保留中文或者a-z或者A-Z)
View Full Code Here

TOP

Related Classes of net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.