/// <summary> /// /// </summary> /// <param name="args"></param> private static void Main(string[] args) { // deal with Chinese sentence { HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); Console.WriteLine("Chinese : 我的中国心"); // defautlt output format Console.WriteLine("defautlt output format 默认输出格式"); Console.WriteLine(PinyinHelper.ToHanyuPinyinString("我的中国心", outputFormat, "")); Console.WriteLine("***"); // with seperater Console.WriteLine("with seperater 空白分割符"); Console.WriteLine(PinyinHelper.ToHanyuPinyinString("我的中国心", outputFormat, " ")); Console.WriteLine("***"); // output uppercase Console.WriteLine("output uppercase 大写输出"); outputFormat.CaseType = HanyuPinyinCaseType.UPPERCASE; Console.WriteLine(PinyinHelper.ToHanyuPinyinString("我的中国心", outputFormat, " ")); Console.WriteLine("***"); // without tone numbers or tone marks Console.WriteLine("without tone numbers or tone marks 无声调模式"); outputFormat.RestoreDefault(); outputFormat.ToneType = HanyuPinyinToneType.WITHOUT_TONE; Console.WriteLine(PinyinHelper.ToHanyuPinyinString("我的中国心", outputFormat, " ")); Console.WriteLine("***"); Console.WriteLine("'ü' 测试"); // use u: as an alternative of 'ü' Console.WriteLine("use u: as an alternative of 'ü' 越女剑"); outputFormat.RestoreDefault(); Console.WriteLine(PinyinHelper.ToHanyuPinyinString("越女剑", outputFormat, " ")); Console.WriteLine("***"); // use v as an alternative of 'ü' Console.WriteLine("use v as an alternative of 'ü' 越女剑"); outputFormat.VCharType = HanyuPinyinVCharType.WITH_V; Console.WriteLine(PinyinHelper.ToHanyuPinyinString("越女剑", outputFormat, " ")); Console.WriteLine("***"); // deal with combination of Chinese and non-Chinese Console.WriteLine("deal with combination of Chinese and non-Chinese 道琼斯指数上扬5%"); outputFormat.RestoreDefault(); Console.WriteLine(PinyinHelper.ToHanyuPinyinString("道琼斯指数上扬5%", outputFormat, " ")); Console.WriteLine("***"); } // deal with Chinese character { HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat(); { // single pronounciation string[] pinyinArray = PinyinHelper.ToHanyuPinyinStringArray('我', outputFormat); Console.WriteLine("***"); for (int i = 0; i < pinyinArray.Length; i++) { StringBuilder stringbuf = new StringBuilder(); stringbuf.Append("pinyin "); stringbuf.Append(i); stringbuf.Append(": "); stringbuf.Append(pinyinArray[i]); Console.WriteLine(stringbuf.ToString()); } Console.WriteLine("***"); } { // multiple pronounciations string[] pinyinArray = PinyinHelper.ToHanyuPinyinStringArray('中', outputFormat); Console.WriteLine("***"); for (int i = 0; i < pinyinArray.Length; i++) { StringBuilder stringbuf = new StringBuilder(); stringbuf.Append("pinyin "); stringbuf.Append(i); stringbuf.Append(": "); stringbuf.Append(pinyinArray[i]); Console.WriteLine(stringbuf.ToString()); } Console.WriteLine("***"); } } //WadeGiles { Console.WriteLine("WadeGiles 拼音方案"); Console.WriteLine(GetWadeGilesPinyinString("我的中国心")); Console.WriteLine(GetWadeGilesPinyinString("拼音方案")); Console.WriteLine(GetWadeGilesPinyinString("北京")); Console.WriteLine(GetWadeGilesPinyinString("台北")); Console.WriteLine(GetWadeGilesPinyinString("国语")); } //Yele { Console.WriteLine("Yele 拼音方案"); Console.WriteLine(GetYelePinyinString("我的中国心")); Console.WriteLine(GetYelePinyinString("拼音方案")); Console.WriteLine(GetYelePinyinString("北京")); Console.WriteLine(GetYelePinyinString("台北")); Console.WriteLine(GetYelePinyinString("国语")); } Console.Read(); }