Public class ChineseBrevityCode
{
/// <Summary>
/// Obtain the simplified Chinese characters
/// </Summary>
/// <Param name = "strText"> </param>
/// <Returns> </returns>
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,452 53, 45761,463 18, 46826,470 10, 47297,476 14, 48119,481 19, 49062,493 24, 49896,503 71, 50614,506 22, 50906,513 87, 51446,522 18, 52698,526 98, 52698,529 80, 53689,544 81 };
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;
}
}