[Csharp]
Namespace shortName
{
Public class Program
{
Public static void Main (string [] args)
{
Program obj = new Program ();
String lxm = string. Empty;
Lxm = obj. GetPYString ("Chongqing store ");
Console. WriteLine (lxm. ToUpper ());
Console. Write ("Press any key to continue ...");
Console. ReadKey (true );
}
/// <Summary>
/// Abbreviated Chinese character to PinYin
/// </Summary>
/// <Param name = "str"> string of Chinese characters to be converted </param>
/// <Returns> pinyin abbreviation </returns>
Public string GetPYString (string str)
{
String tempStr = "";
Foreach (char c in str)
{
If (int) c >=33 & (int) c <= 126)
{// Reserved letters and symbols
TempStr + = c. ToString ();
}
Else
{// Accumulate the pinyin initials
TempStr + = GetPYChar (c. ToString ());
}
}
Return tempStr;
}
/// <Summary>
/// Obtain the pinyin initials of a single character
/// </Summary>
/// <Param name = "c"> single Chinese character to be converted </param>
/// <Returns> pinyin initials </returns>
Public string GetPYChar (string c)
{
Byte [] array = new byte [2];
Array = System. Text. Encoding. Default. GetBytes (c );
Int I = (short) (array [0]-'\ 0') * 256 + (short) (array [1]-' \ 0 '));
If (I <0xB0A1) return "*";
If (I <0xB0C5) return "";
If (I <0xB2C1) return "B ";
If (I <0xB4EE) return "c ";
If (I <0xB6EA) return "d ";
If (I <0xB7A2) return "e ";
If (I <0xB8C1) return "f ";
If (I <0xB9FE) return "g ";
If (I <0xBBF7) return "h ";
If (I <0xBFA6) return "g ";
If (I <0xC0AC) return "k ";
If (I <0xC2E8) return "l ";
If (I <0xC4C3) return "m ";
If (I <0xC5B6) return "n ";
If (I <0xC5BE) return "o ";
If (I <0xC6DA) return "p ";
If (I <0xC8BB) return "q ";
If (I <0xC8F6) return "r ";
If (I <0 xCBFA) return "s ";
If (I <0 xCDDA) return "t ";
If (I <0xCEF4) return "w ";
If (I <0xD1B9) return "x ";
If (I <0xD4D1) return "y ";
If (I <0xD7FA) return "z ";
Return "*";
}
}
}