c#写汉字第一个拼音
来源:互联网 发布:甘肃网络干部学院登录 编辑:程序博客网 时间:2024/04/28 00:28
public static string GetCodstring(string UnName)
{
int i = 0;
ushort key = 0;
string strResult = string.Empty;
//创建两个不同的encoding对象
Encoding unicode = Encoding.Unicode;
//创建GBK码对象
Encoding gbk = Encoding.GetEncoding(936);
//将unicode字符串转换为字节
byte[] unicodeBytes = unicode.GetBytes(UnName);
//再转化为GBK码
byte[] gbkBytes = Encoding.Convert(unicode, gbk, unicodeBytes);
while (i < gbkBytes.Length)
{
//如果为数字/字母/其他ASCII符号
if (gbkBytes[i] <= 127)
{
strResult = strResult + (char)gbkBytes[i];
i++;
}
#region 否则生成汉字拼音简码,取拼音首字母
else
{
key = (ushort)(gbkBytes[i] * 256 + gbkBytes[i + 1]);
if (key >= '/uB0A1' && key <= '/uB0C4')
{
strResult = strResult + "A";
}
else if (key >= '/uB0C5' && key <= '/uB2C0')
{
strResult = strResult + "B";
}
else if (key >= '/uB2C1' && key <= '/uB4ED')
{
strResult = strResult + "C";
}
else if (key >= '/uB4EE' && key <= '/uB6E9')
{
strResult = strResult + "D";
}
else if (key >= '/uB6EA' && key <= '/uB7A1')
{
strResult = strResult + "E";
}
else if (key >= '/uB7A2' && key <= '/uB8C0')
{
strResult = strResult + "F";
}
else if (key >= '/uB8C1' && key <= '/uB9FD')
{
strResult = strResult + "G";
}
else if (key >= '/uB9FE' && key <= '/uBBF6')
{
strResult = strResult + "H";
}
else if (key >= '/uBBF7' && key <= '/uBFA5')
{
strResult = strResult + "J";
}
else if (key >= '/uBFA6' && key <= '/uC0AB')
{
strResult = strResult + "K";
}
else if (key >= '/uC0AC' && key <= '/uC2E7')
{
strResult = strResult + "L";
}
else if (key >= '/uC2E8' && key <= '/uC4C2')
{
strResult = strResult + "M";
}
else if (key >= '/uC4C3' && key <= '/uC5B5')
{
strResult = strResult + "N";
}
else if (key >= '/uC5B6' && key <= '/uC5BD')
{
strResult = strResult + "O";
}
else if (key >= '/uC5BE' && key <= '/uC6D9')
{
strResult = strResult + "P";
}
else if (key >= '/uC6DA' && key <= '/uC8BA')
{
strResult = strResult + "Q";
}
else if (key >= '/uC8BB' && key <= '/uC8F5')
{
strResult = strResult + "R";
}
else if (key >= '/uC8F6' && key <= '/uCBF9')
{
strResult = strResult + "S";
}
else if (key >= '/uCBFA' && key <= '/uCDD9')
{
strResult = strResult + "T";
}
else if (key >= '/uCDDA' && key <= '/uCEF3')
{
strResult = strResult + "W";
}
else if (key >= '/uCEF4' && key <= '/uD188')
{
strResult = strResult + "X";
}
else if (key >= '/uD1B9' && key <= '/uD4D0')
{
strResult = strResult + "Y";
}
else if (key >= '/uD4D1' && key <= '/uD7F9')
{
strResult = strResult + "Z";
}
else
{
strResult = strResult + "?";
}
i = i + 2;
}
#endregion
}//end while
return strResult;
}
- c#写汉字第一个拼音
- 获取汉字第一个拼音 c# asp.net 2.0
- C#获得汉字拼音的第一个字母
- 获取汉字拼音的第一个字母
- c#获得汉字的第一个字母,方便用拼音码查数据
- ASP中获取汉字拼音的第一个字母
- 显示汉字的拼音的第一个字母.
- asp中获取汉字拼音的第一个字母
- 自动将汉字转换成拼音第一个字母
- 汉字按拼音的第一个字母排序
- 把汉字转换成拼音第一个字母
- 将汉字转换成拼音第一个字母
- javascript 获得汉字拼音的第一个字母
- mysql 按照 汉字的第一个拼音排序
- 汉字转拼音,并返回第一个字母
- 用C#写的将汉字转换为拼音首字母
- C# 获取汉字拼音
- c# 汉字转拼音
- AT&T汇编与Intel汇编的一些区别
- 2563 递推题
- 关于bi_sector 的问题
- 【转】下载安装离线版维基百科
- c# web 后台嵌入media
- c#写汉字第一个拼音
- UNIX中各种网络异常情况下的处理
- Some commonly used commands in linux
- c# Queue 先进先出队列
- INFORMIX health check
- 组件图
- Oracle:表名、字段名、constraint名的长度有限制
- c# 单重继承
- 从一段小小的C语言程序说起(1)