| 英汉字典暂时放一放了,准备考虑汉英字典。本来以为很难,看了些贴子。发现将词典按拼音排序后,就和英汉差不多了。关键是就是如何取得汉字的拼音了,baidu一下,发现了这篇文章,特留下来以作参考。 #region "从汉字获取拼音" //*************************************************************************** //名 称: GetChinesePYCode //功 能: 获取汉字字符串的声母 //输 入: //输 出: //*************************************************************************** public static string GetChinesePYCode(string strChinese) { string strRet=""; for(int i=0;istrRet +=GetChineseWordPYCode(strChinese.Substring(i,1)); return strRet; } //**************************************** //取的一个汉字的首字母 private static string GetChineseWordPYCode(string strChineseWord) { long HZ_INT; byte[] bt = System.Text.Encoding.Default.GetBytes(strChineseWord);
if(bt.Length<2) //本身就是拼音 return strChineseWord;
int i1 = (short)(bt[0]); int i2 = (short)(bt[1]); HZ_INT=i1*256+i2; // expresstion //table of the constant list // 'A'; //45217..45252 // 'B'; //45253..45760 // 'C'; //45761..46317 // 'D'; //46318..46825 // 'E'; //46826..47009 // 'F'; //47010..47296 // 'G'; //47297..47613
// 'H'; //47614..48118 // 'J'; //48119..49061 // 'K'; //49062..49323 // 'L'; //49324..49895 // 'M'; //49896..50370 // 'N'; //50371..50613 // 'O'; //50614..50621 // 'P'; //50622..50905 // 'Q'; //50906..51386
// 'R'; //51387..51445 // 'S'; //51446..52217 // 'T'; //52218..52697 //没有U,V // 'W'; //52698..52979 // 'X'; //52980..53640 // 'Y'; //53689..54480 // 'Z'; //54481..55289
// HZ_INT match the constant if ((HZ_INT>=45217) && (HZ_INT<=45252)) { return "a"; } if ((HZ_INT>=45253) && (HZ_INT<=45760)) { return "b"; } if ((HZ_INT>=45761) && (HZ_INT<=46317)) { return "c";
} if ((HZ_INT>=46318) && (HZ_INT<=46825)) { return "d"; } if ((HZ_INT>=46826) && (HZ_INT<=47009)) { return "e"; } if ((HZ_INT>=47010) && (HZ_INT<=47296)) { return "f"; } if ((HZ_INT>=47297) && (HZ_INT<=47613)) { return "g"; } //************************** if ((HZ_INT>=47614) && (HZ_INT<=48118)) { //MessageBox.Show("H"); return "h"; }
if ((HZ_INT>=48119) && (HZ_INT<=49061)) { return "j"; } if ((HZ_INT>=49062) && (HZ_INT<=49323)) { return "k"; } if ((HZ_INT>=49324) && (HZ_INT<=49895)) { return "l"; } if ((HZ_INT>=49896) && (HZ_INT<=50370)) { return "m"; }
if ((HZ_INT>=50371) && (HZ_INT<=50613)) { return "n";
} if ((HZ_INT>=50614) && (HZ_INT<=50621)) { return "o"; } if ((HZ_INT>=50622) && (HZ_INT<=50905)) { return "p";
} if ((HZ_INT>=50906) && (HZ_INT<=.51386)) { return "q";
} //********************* if ((HZ_INT>=51387) && (HZ_INT<=51445)) { return "r"; } if ((HZ_INT>=51446) && (HZ_INT<=52217)) { return "s"; } if ((HZ_INT>=52218) && (HZ_INT<=52697)) { return "t"; } if ((HZ_INT>=52698) && (HZ_INT<=52979)) { return "w"; } if ((HZ_INT>=52980) && (HZ_INT<=53640)) { return "x"; } if ((HZ_INT>=53689) && (HZ_INT<=54480)) { return "y"; } if ((HZ_INT>=54481) && (HZ_INT<=55289)) { return "z"; } return ""; } #endregion
|