留下email发一个给你看看

解决方案 »

  1.   

    我要写类方法的数据库的就不用了,谢谢,油箱[email protected]
      

  2.   

    以前找过一个简单的实现这种功能的类,用着还可以,缺点是不能处理多音字,要处理多音字那就得建立数据库了在我的网络U盘电子书文件夹下
    http://lxcnn.5u6.net/index.aspx
      

  3.   

    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;
            }