.Net、C# 汉字转拼音,简体繁体转换方法
2021-04-26 00:26
标签:开发环境 cin converter targe nta 字符 reac asi target 实例代码: 源码: 结果: .Net、C# 汉字转拼音,简体繁体转换方法 标签:开发环境 cin converter targe nta 字符 reac asi target 原文地址:http://www.cnblogs.com/zzp0320/p/7908425.html1 Microsoft.International.Converters.PinYinConverter.ChineseChar cc=new Microsoft.International.Converters.PinYinConverter.ChineseChar(‘国‘);
1 string temp_1 = Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter.ChineseConverter.Convert("中华人民共和国",
2
3 Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter.ChineseConversionDirection.SimplifiedToTraditional);
1 string temp_2 = Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter.ChineseConverter.Convert(temp_1,
2
3 Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter.ChineseConversionDirection.TraditionalToSimplified);
1 1 string temp_4 = string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:L}", 1234567890.45);
1 string temp_6 = string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:Ln}", 1234567890.45);
1 string temp_7 = string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:Lc}", 1234567890.45);
//简体/繁体切换
string
temp_1 = ChineseConverter.Convert(
"中国人"
, ChineseConversionDirection.TraditionalToSimplified);
string
temp_2 = ChineseConverter.Convert(
"中国人"
, ChineseConversionDirection.SimplifiedToTraditional);
Console.WriteLine(
"简体转换:"
+temp_1+
"\n繁体转换:"
+temp_2);
//汉字转换拼音
string
r =
string
.Empty;
Console.Write(
"请输入任意汉字:"
);
string
str = Console.ReadLine();
foreach
(
char
obj
in
str)
{
try
{
ChineseChar chineseChar =
new
ChineseChar(obj);
string
t = chineseChar.Pinyins[0].ToString();
r += t.Substring(0, t.Length - 1);
}
catch
{
r += obj.ToString();
}
}
Console.WriteLine(r.ToLower().ToString());
文章标题:.Net、C# 汉字转拼音,简体繁体转换方法
文章链接:http://soscw.com/index.php/essay/79580.html