如何根据汉字来检索拼音(只要首字母就行)-----------在线给分 留下email发一个给你看看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我要写类方法的数据库的就不用了,谢谢,油箱[email protected] 以前找过一个简单的实现这种功能的类,用着还可以,缺点是不能处理多音字,要处理多音字那就得建立数据库了在我的网络U盘电子书文件夹下http://lxcnn.5u6.net/index.aspx public static 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; } private static 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) }); } } return "*"; } else return cnChar; } asp.net要怎么样在一个页面中引用另一个页面? C# 调用dll的结构的指针的指针 C#编写的 wince串口程序调不通,怎么办啊? 哪位大侠说说Jaccard算法的思想 showdialog()问题 求:涉及到多线程的UML Sequence的画法。 DataGrid 中有 Columns ,其中每一列的索引可以变吗? 在winform中如何设置gridview中的光标? winform C#怎么让checkedlistbox最多只能选中3项 请问如何用c#实现socket 通讯? 【求助】DoubleClick事件的双击问题,在线等! C#奇怪的问题!
http://lxcnn.5u6.net/index.aspx
{
int len = strText.Length;
string myStr = "";
for (int i = 0; i < len; i++)
{
myStr += getSpell(strText.Substring(i, 1));
}
return myStr;
} private static 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) });
}
}
return "*";
}
else return cnChar;
}