/// <Summary>
/// Static method to obtain the first letter of a character in Chinese pinyin
/// </Summary>
/// <Param name = "cnChar">
/// String for which the first letter of the Pinyin is to be calculated
/// </Param>
Public static System. String getSpell (System. String cnChar)
{
System. Byte [] arrCN = System. Text. Encoding. Default. GetBytes (cnChar );
If (arrCN. Length> 1)
{
System. Int32 area = (System. Int16) arrCN [0];
System. Int32 pos = (System. Int16) arrCN [1];
System. Int32 code = (area <8) + pos;
System. int32 [] 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 (System. Int32 I = 0; I <26; I ++)
{
System. Int32 max = 55290;
If (I! = 25)
{
Max = areacode [I + 1];
}
If (areacode [I] <= code & code <max)
{
Return System. Text. Encoding. Default. GetString (new System. Byte [] {(System. Byte) (65 + I )});
}
}
Return "*";
}
Else
{
Return cnChar;
}
}