汉字转拼音Pinyin4j工具(C#、Java都可用)

时间:2022-09-26 16:12:35

C#用法:

string pinyin=GetStringPinYin("张三");
//方法如下
public static string GetStringPinYin(string hanzi)
{
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.ToneType = HanyuPinyinToneType.WITHOUT_TONE;
format.VCharType = HanyuPinyinVCharType.WITH_U_UNICODE;
format.CaseType = HanyuPinyinCaseType.UPPERCASE; return PinyinHelper.ToHanyuPinyinString(hanzi, format, "");
}

参考:

http://www.cnblogs.com/bluestorm/archive/2012/07/23/2605412.html

http://blog.csdn.net/gebitan505/article/details/15501523