获取汉字第一个拼音 c# asp.net 2.0
2007-08-15 16:48
726 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//// <summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// 获取汉字第一个拼音
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// </summary>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
/// <param name="input"></param>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
/// <returns></returns>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
static public string getSpells(string input)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...#region
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int len = input.Length;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string reVal = "";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < len; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
reVal += getSpell(input.Substring(i, 1));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return reVal;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](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/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...#region
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
byte[] arrCN = Encoding.Default.GetBytes(cn);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (arrCN.Length > 1)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int area = (short)arrCN[0];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int pos = (short)arrCN[1];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int code = (area << 8) + pos;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.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 };
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < 26; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int max = 55290;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i != 25) max = areacode[i + 1];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (areacode[i] <= code && code < max)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
return Encoding.Default.GetString(new byte[] ...{ (byte)(65 + i) });
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return "?";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else return cn;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- c# asp.net 2.0 获取汉字第一个拼音
- ASP.NET 根据汉字获取汉字拼音的首字母(含多音字)
- asp中获取汉字拼音的第一个字母
- asp.net汉字转拼音和获取汉字首字母的代码
- ASP.NET中如何获取汉字的拼音
- ASP.NET获取汉字拼音的首字母
- ASP.NET 根据汉字获取汉字拼音的首字母(含多音字)
- asp.net汉字转拼音和获取汉字首字母的代码
- asp.net 获取汉字字符串的拼音首字母,含多音字
- [Asp.Net WinForm]利用Visual Studio International Pack来获取汉字的拼音缩写
- 取得汉字拼音首字母 (asp.net C#)
- ASP.NET获取汉字拼音的首字母
- ASP.NET汉字转拼音 - 输入汉字获取其拼音的具体实现
- ASP.NET汉字转拼音 - 输入汉字获取其拼音的具体实现
- asp.net 自动将汉字转换成拼音第一个字母
- ASP.NET获取汉字拼音的首字母
- ASP.NET获取汉字拼音的首字母
- asp.net中C#获取字符串中汉字的个数的具体实现方法