asp.net中文转换成拼音首字母
2008-07-15 15:11
567 查看
private static string getPinYin(string text)
{
char pinyin;
byte[] array;
System.Text.StringBuilder sb = new System.Text.StringBuilder(text.Length);
foreach (char c in text)
{
pinyin = c;
array = System.Text.Encoding.Default.GetBytes(new char[] { c });
if (array.Length == 2)
{
int i = array[0] * 0x100 + array[1];
if (i < 0xB0A1) pinyin = c;
else
if (i < 0xB0C5) pinyin = 'a';
else
if (i < 0xB2C1) pinyin = 'b';
else
if (i < 0xB4EE) pinyin = 'c';
else
if (i < 0xB6EA) pinyin = 'd';
else
if (i < 0xB7A2) pinyin = 'e';
else
if (i < 0xB8C1) pinyin = 'f';
else
if (i < 0xB9FE) pinyin = 'g';
else
if (i < 0xBBF7) pinyin = 'h';
else
if (i < 0xBFA6) pinyin = 'g';
else
if (i < 0xC0AC) pinyin = 'k';
else
if (i < 0xC2E8) pinyin = 'l';
else
if (i < 0xC4C3) pinyin = 'm';
else
if (i < 0xC5B6) pinyin = 'n';
else
if (i < 0xC5BE) pinyin = 'o';
else
if (i < 0xC6DA) pinyin = 'p';
else
if (i < 0xC8BB) pinyin = 'q';
else
if (i < 0xC8F6) pinyin = 'r';
else
if (i < 0xCBFA) pinyin = 's';
else
if (i < 0xCDDA) pinyin = 't';
else
if (i < 0xCEF4) pinyin = 'w';
else
if (i < 0xD1B9) pinyin =
'x';
else
if (i < 0xD4D1)
pinyin = 'y';
else
if (i < 0xD7FA)
pinyin = 'z';
}
sb.Append(pinyin);
}
return sb.ToString();
}
{
char pinyin;
byte[] array;
System.Text.StringBuilder sb = new System.Text.StringBuilder(text.Length);
foreach (char c in text)
{
pinyin = c;
array = System.Text.Encoding.Default.GetBytes(new char[] { c });
if (array.Length == 2)
{
int i = array[0] * 0x100 + array[1];
if (i < 0xB0A1) pinyin = c;
else
if (i < 0xB0C5) pinyin = 'a';
else
if (i < 0xB2C1) pinyin = 'b';
else
if (i < 0xB4EE) pinyin = 'c';
else
if (i < 0xB6EA) pinyin = 'd';
else
if (i < 0xB7A2) pinyin = 'e';
else
if (i < 0xB8C1) pinyin = 'f';
else
if (i < 0xB9FE) pinyin = 'g';
else
if (i < 0xBBF7) pinyin = 'h';
else
if (i < 0xBFA6) pinyin = 'g';
else
if (i < 0xC0AC) pinyin = 'k';
else
if (i < 0xC2E8) pinyin = 'l';
else
if (i < 0xC4C3) pinyin = 'm';
else
if (i < 0xC5B6) pinyin = 'n';
else
if (i < 0xC5BE) pinyin = 'o';
else
if (i < 0xC6DA) pinyin = 'p';
else
if (i < 0xC8BB) pinyin = 'q';
else
if (i < 0xC8F6) pinyin = 'r';
else
if (i < 0xCBFA) pinyin = 's';
else
if (i < 0xCDDA) pinyin = 't';
else
if (i < 0xCEF4) pinyin = 'w';
else
if (i < 0xD1B9) pinyin =
'x';
else
if (i < 0xD4D1)
pinyin = 'y';
else
if (i < 0xD7FA)
pinyin = 'z';
}
sb.Append(pinyin);
}
return sb.ToString();
}
相关文章推荐
- asp.net 将中文汉字转换为英文首字母和将汉字转换为拼音全拼
- asp.net 自动将汉字转换成拼音第一个字母
- asp.net 汉字转换拼音及首字母实现代码
- asp.net 自动将汉字转换成拼音第一个字母
- asp.net 汉字转换拼音及首字母实现代码
- Asp.net 将中文汉字转换成拼音首字和拼音全拼
- asp.net 汉字转换拼音及首字母实现代码
- ASP.NET 根据汉字获取汉字拼音的首字母(含多音字)
- -asp网站的按字母查询- [JS] 获取中文字符串拼音首字母串的函数
- ASP.NET获取汉字拼音的首字母
- C#汉字转拼音(npinyin)将中文转换成拼音全文或首字母
- asp.net汉字转拼音和获取汉字首字母的代码
- ASP.net textbox输入自动转换大小写字母
- 汉字转拼音ASP中文转换
- asp.net获取中文汉字的首字母
- C#汉字转拼音(npinyin)将中文转换成拼音全文或首字母
- asp.net 中将汉字转换成拼音
- asp.net拼音转换成汉字
- ASP.NET输入汉字返回每个汉字拼音的头一个字母的大写形式
- asp.net汉字转拼音和获取汉字首字母的代码