# Region getchinesespell get the first letter of Chinese pinyin
// Obtain the first letter of Chinese pinyin
Static Public 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;
}
Static Public String [] getchinesespell (string [] strtext)
{
Int Len = strtext. length;
String [] mystr = NULL;
For (INT I = 0; I <Len; I ++)
{
Mystr [I] = getspell (strtext [I]);
}
Return mystr;
}
Static Public 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;
}
# Endregion