package com.sucre; //所需导入的jar包在下侧下载0 O% y2 ?* R# f* c/ |
import net.sourceforge.pinyin4j.PinyinHelper;) a# [0 \% A) E4 d8 @ t" y
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;7 K+ S% I1 Q/ \& |" x
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
X0 J5 f. ]+ ]: J; j; n import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
2 ~/ E: u; h4 N1 T+ A import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
r6 H& F4 @8 p# N- z# F: [+ a import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
) f4 T4 `5 }& ~" w5 q public class ChineseToEnglish1 s/ `, y' M# E
{
6 ^) W- k; w/ \ u( T //------------------------将汉字转换为全拼-------------------------------" Y" l6 r! c5 k7 I0 o, K7 T/ z
public static String getPingYin(String src){
! g/ N; t2 V+ r/ u; l1 g char[] t1 = null;0 C$ Y! w( ~" a& s
t1=src.toCharArray();
& Z+ u% f$ @: q9 L- l" h% y, b String[] t2 = new String[t1.length];
, b* c# f, J# Q2 a, r! A, M HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat();8 s+ [/ S& ]! Z
t3.setCaseType(HanyuPinyinCaseType.LOWERCASE);' e7 L# E0 N. {2 |3 V) g% [
t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE);, ^ R# q1 y1 n8 I* f
t3.setVCharType(HanyuPinyinVCharType.WITH_V);7 K# F, T" x! F" q' S" F u$ W0 i2 i
String t4="";. f' B$ i5 ~- c( {9 i7 n% D
int t0=t1.length;
) _1 ^- Y6 o2 `$ M% ~ try {& Q) @& M% `% }7 m( N# j7 N5 W
+ u9 T+ L- K2 e. W* Z# o& [
for (int i=0;i |