wince +C#拼音码形成代码
2013-11-02 15:47
204 查看
#region//汉字形成拼音简码
static public string GetChineseSpell(string strText)
{
int len = strText.Length;
string myStr = "";
for (int i = 0; i < len; i++)
{
myStr += getSpell(strText.Substring(i, 1));
}
return myStr;
}
static public string getSpell(string cnChar)
{
byte[] arrCN = Encoding.Default.GetBytes(cnChar);
if (arrCN.Length > 1)
{
int area = (short)arrCN[0];
int pos = (short)arrCN[1];
int code = (area << 8) + pos;
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++)
{
int max = 55290;
if (i != 25) max = areacode[i + 1];
if (areacode[i] <= code && code < max)
{
return Encoding.Default.GetString(new byte[] { (byte)(65 + i) },0,1);
//wince环境下没有GetString()这个函数
}
}
return "*";
}
else return cnChar;
}
#endregion
static public string GetChineseSpell(string strText)
{
int len = strText.Length;
string myStr = "";
for (int i = 0; i < len; i++)
{
myStr += getSpell(strText.Substring(i, 1));
}
return myStr;
}
static public string getSpell(string cnChar)
{
byte[] arrCN = Encoding.Default.GetBytes(cnChar);
if (arrCN.Length > 1)
{
int area = (short)arrCN[0];
int pos = (short)arrCN[1];
int code = (area << 8) + pos;
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++)
{
int max = 55290;
if (i != 25) max = areacode[i + 1];
if (areacode[i] <= code && code < max)
{
return Encoding.Default.GetString(new byte[] { (byte)(65 + i) },0,1);
//wince环境下没有GetString()这个函数
}
}
return "*";
}
else return cnChar;
}
#endregion
相关文章推荐
- Entity Framework 实体框架的形成之旅--几种数据库操作的代码介绍(9)
- python 从两个配置文件读取数据,形成一个url思路代码
- pmtest6.asm代码详细解释,对分页的形成过程有详细的解释
- poj1230 Pass-Muraille 贪心算法,形成良好的代码风格很重要
- 1.3.5 函数风格如何形成代码
- android项目后期优化-----代码重新封装/形成框架意识(http请求)
- poj1230 Pass-Muraille 贪心算法,形成良好的代码风格很重要
- 通过复杂的代码形成业务数据并显示的思路 游标 存储过程
- 应该形成清晰的代码风格
- 谋篇布局:高效形成代码的心得
- 16、把相同或近乎相同的代码形成函数和宏
- WCF开发框架形成之旅---结合代码生成工具实现快速开发
- Android 浅谈模式之一 拆分代码形成 MVC 模式
- js形成页面的一种遮罩效果实例代码
- 通过复杂的代码形成业务数据并显示的思路 游标 存储过程
- 以 lower_bound 函数入门二分搜索(形成自己的代码风格)
- 有限元算法-4:有限元代码(由Shell63,Solid45,Fluid30组合在一起形成的耦合程序)
- 【九度】抓取九度AC所有代码以及在CSDN的解题思路链接形成文件提交至github
- WCF开发框架形成之旅---结合代码生成工具实现快速开发
- C#为什么要形成IL中间代码,而不是直接生成机器代码?