1.java tochararrayԴ??
java tochararrayԴ??
下面是中文转换成拼音的一个程序。需要下载jar包!西瓜直播助手源码下载不到的农场复利源码交易平台可以来找我!
可以生成 中国 zhongguo 或zg
package cn;
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.exception.BadHanyuPinyinOutputFormatCombination;
/**
* 汉字转换位汉语拼音,美容o2o平台源码英文字符不变
*
* @author xuke
*
*/
public class Pinyin4J {
/**
* 汉字转换位汉语拼音首字母,网页上看不到js源码英文字符不变
*
* @param chines
* 汉字
* @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] > ) {
try {
pinyinName += PinyinHelper.toHanyuPinyinStringArray(
nameChar[i],中药材大全网站源码 defaultFormat)[0].charAt(0);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pinyinName += nameChar[i];
}
}
return pinyinName;
}
/**
* 汉字转换位汉语拼音,英文字符不变
*
* @param chines
* 汉字
* @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] > ) {
try {
pinyinName += PinyinHelper.toHanyuPinyinStringArray(
nameChar[i], defaultFormat)[0];
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pinyinName += nameChar[i];
}
}
return pinyinName;
}
public static void main(String[] args) {
System.out.println(converterToSpell("百度"));
}
}
2024-11-25 09:40
2024-11-25 09:00
2024-11-25 08:36
2024-11-25 07:23
2024-11-25 07:20
2024-11-25 07:15