最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 通过拼音搜索中文的方法
时间:2022-07-02 11:27:16 编辑:袖梨 来源:一聚教程网
///
/// 静态方法,获取一个字符的汉字拼音的首字母
///
///
/// 需要计算拼音首字母的串
///
public static System.String getSpell(System.String cnChar)
{
System.Byte[] arrCN = System.Text.Encoding.Default.GetBytes(cnChar);
if (arrCN.Length > 1)
{
System.Int32 area = (System.Int16)arrCN[0];
System.Int32 pos = (System.Int16)arrCN[1];
System.Int32 code = (area << 8) + pos;
System.Int32[] areacode = { 45217, 45253, 45761, 46318, 46826, 47010, 47297, 47614, 48119, 48119, 49062, 49324, 49896, 50371, 50614, 50622, 50906, 51387, 51446, 52218, 52698, 52698, 52698, 52980, 53689, 54481 };
for (System.Int32 i = 0; i < 26; i++)
{
System.Int32 max = 55290;
if (i != 25)
{
max = areacode[i + 1];
}
if (areacode[i] <= code && code < max)
{
return System.Text.Encoding.Default.GetString(new System.Byte[] { (System.Byte)(65 + i) });
}
}
return "*";
}
else
{
return cnChar;
}
}
相关文章
- 燕云十六声最新全门派 晋升地位攻略及门规 07-01
- 策略:如何买币:新手指南,轻松入门加密货币投资 07-01
- 软件工程师向XRP持有者发出关键安全警告 07-01
- 最终幻想14水晶世界配置要求 FF14手游设备推荐 07-01
- 王者荣耀云中君云械蓝图怎么获得 07-01
- ps利用锐化和曲线工具精修拉丝金属钻戒图片教程 07-01