1 public class CNToSpell 2 { 3 /// 汉字转拼音缩写 4 /// Code By MuseStudio@hotmail.com 5 /// 2004-11-30 6 /// 要转换的汉字字符串/// 拼音缩写 7 public static string GetString(string str) 8 { 9 string tempStr = ""; 10 foreach (char c in str) 11 { 12 if ((int)c >= 33 && (int)c <= 126) 13 { 14 //字母和符号原样保留 15 tempStr += c.ToString(); 16 } 17 else 18 { 19 //累加拼音声母 20 tempStr += GetPYChar(c.ToString()); 21 } 22 } 23 return tempStr; 24 } 25 26 /// Code By MuseStudio@hotmail.com 27 /// 2004-11-30 28 /// 要转换的单个汉字/// 拼音声母 29 private static string GetPYChar(string c) 30 { 31 byte[] array = new byte[2]; 32 array = System.Text.Encoding.Default.GetBytes(c); 33 int i = (short)(array[0] - '