-
c# asp.net 2.0 获取汉字第一个拼音
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
/**//// <summary>
/// 获取汉字第一个拼音
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
static public string getSpells(string input)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...#region
int len = input.Length;
string reVal = "";
for (int i = 0; i < len; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
reVal += getSpell(input.Substring(i, 1));
}
return reVal;
#endregion
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
static public string getSpell(string cn)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...#region
byte[] arrCN = Encoding.Default.GetBytes(cn);
if (arrCN.Length > 1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
int area = (short)arrCN[0];
int pos = (short)arrCN[1];
int code = (area << 8) + pos;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
int[] 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 (int i = 0; i < 26; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
int max = 55290;
if (i != 25) max = areacode[i + 1];
if (areacode[i] <= code && code < max)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
return Encoding.Default.GetString(new byte[] ...{ (byte)(65 + i) });
}
}
return "?";
}
else return cn;
#endregion
}
-
相关阅读:
【原创】NOR FLASH Block Unprotection
虚拟机:Snapshot
Struts2:简单登陆验证DAO VO ACTION
Cocos2dx:安装
LoadRunner:Socket+Http协议
LoadRunner中添加外部文件(md5.h),使用MD5
Javascript实现网页水印(非图片水印)
ASP.NET网站限制访问频率
再谈“ASP.NET网站限制恶意访问”
【新闻】“赢在淘宝”b比赛 30强、10强火热出炉~!
-
原文地址:https://www.cnblogs.com/lds85930/p/1207751.html
Copyright © 2020-2023
润新知