/// <summary>
/// 获取中文字符串的首字母
/// </summary>
/// <param name="strText"></param>
/// <returns></returns>
public static string GetChineseSpell(string strText)
{
int len = strText.Length;
string myStr = "";
for (int i = ; i < len; i++)
{
myStr += getSpell(strText.Substring(i, ));
}
return myStr;
} /// <summary>
/// 获取单个中文的首字母
/// </summary>
/// <param name="cnChar"></param>
/// <returns></returns>
private static string getSpell(string cnChar)
{
byte[] arrCN = Encoding.Default.GetBytes(cnChar);
if (arrCN.Length > )
{
int area = (short)arrCN[];
int pos = (short)arrCN[];
int code = (area << ) + pos;
int[] areacode = { , , , , , , , , , , , , , , , , , , , , , , , , , }; for (int i = ; i < ; i++)
{
int max = ;
if (i != )
{
max = areacode[i + ];
}
if (areacode[i] <= code && code < max)
{
return Encoding.Default.GetString(new byte[] { (byte)( + i) });
}
}
return "*";
}
else return cnChar;
}