国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
pinyin4j簡介

pinyin4j的主頁:http://pinyin4j.sourceforge.net/

pinyin4j能夠根據(jù)中文字符獲取其對應(yīng)的拼音,而且拼音的格式可以定制。

特征:

1. 支持多種拼音系統(tǒng):

 

  • 漢語拼音
  • 通用拼音
  • 威氏拼音
  • 注音二式
  • 雅禮
  • 國語羅馬字

2. 支持多音字

    能夠根據(jù)上下文獲得正確的拼音

3. 支持多種拼音格式

 

  • 大小寫
  • 支持unicode ü 、v 和 u
  • 支持數(shù)字音調(diào)(lü3)、音調(diào)符號 (lǚ)和無音調(diào)標識(lü)

import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;

public class Pinyin
{
/**
* 將漢字轉(zhuǎn)換為全拼
*
* @param src
* @return String
*/
public static String getPinYin(String src)
{
   char[] t1 = null;
   t1 = src.toCharArray();
   // System.out.println(t1.length);
   String[] t2 = new String[t1.length];
   // System.out.println(t2.length);
   // 設(shè)置漢字拼音輸出的格式
   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++)
    {
     // 判斷能否為漢字字符
     // System.out.println(t1[i]);
     if (Character.toString(t1[i]).matches("[\\u4E00-\\u9FA5]+"))
     {
      t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3);// 將漢字的幾種全拼都存到t2數(shù)組中
      t4 += t2[0];// 取出該漢字全拼的第一種讀音并連接到字符串t4后
     }
     else
     {
      // 如果不是漢字字符,間接取出字符并連接到字符串t4后
      t4 += Character.toString(t1[i]);
     }
    }
   }
   catch (BadHanyuPinyinOutputFormatCombination e)
   {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
   return t4;
}

/**
* 提取每個漢字的首字母
*
* @param str
* @return String
*/
public static String getPinYinHeadChar(String str)
{
   String convert = "";
   for (int j = 0; j < str.length(); j++)
   {
    char word = str.charAt(j);
    // 提取漢字的首字母
    String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
    if (pinyinArray != null)
    {
     convert += pinyinArray[0].charAt(0);
    }
    else
    {
     convert += word;
    }
   }
   return convert;
}

/**
* 將字符串轉(zhuǎn)換成ASCII碼
*
* @param cnStr
* @return String
*/
public static String getCnASCII(String cnStr)
{
   StringBuffer strBuf = new StringBuffer();
   // 將字符串轉(zhuǎn)換成字節(jié)序列
   byte[] bGBK = cnStr.getBytes();
   for (int i = 0; i < bGBK.length; i++)
   {
    // System.out.println(Integer.toHexString(bGBK[i] & 0xff));
    // 將每個字符轉(zhuǎn)換成ASCII碼
    strBuf.append(Integer.toHexString(bGBK[i] & 0xff));
   }
   return strBuf.toString();
}

public static void main(String[] args)
{
   String cnStr = "嘅囧誰說壞學生來勼髮視頻襠児";
   System.out.println(getPinYin(cnStr));
   System.out.println(getPinYinHeadChar(cnStr));
   System.out.println(getCnASCII(cnStr));
}
}

 

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
中文轉(zhuǎn)換為全拼和首字母
java漢字轉(zhuǎn)拼音以及得到首字母通用方法
Java中實現(xiàn)漢字生成拼音首拼和五筆碼
使用pinyin4j將中文轉(zhuǎn)換為漢語拼音
iOS 使用CFStringTransform漢字轉(zhuǎn)拼音
pinyin4j學習筆記
更多類似文章 >>
生活服務(wù)
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服