public class Getch2spell {
public static int Compare (string str1, String str2)
{
int result = 0;
String m_s1 = null;
String m_s2 = null;
Try
{
M_S1 = new String (Str1.getbytes (_fromencode_), _toencode_);
M_s2 = new String (Str2.getbytes (_fromencode_), _toencode_);
}
catch (Exception e)
{
Return Str1.compareto (STR2);
}
result = Chinesecompareto (M_S1, M_S2);
return result;
}
public static int Getcharcode (String s)
{
if (s = = null && s.equals (""))
return-1;
byte b[] = S.getbytes ();
int value = 0;
for (int i = 0; i < b.length && i <= 2; i++)
Value = value * + b[i];
return value;
}
public static int Chinesecompareto (string s1, string s2)
{
int len1 = S1.length ();
int len2 = S2.length ();
int n = math.min (len1, len2);
for (int i = 0; i < n; i++)
{
int s1_code = Getcharcode (S1.charat (i) + "");
int s2_code = Getcharcode (S2.charat (i) + "");
if (S1_code * S2_code < 0)
Return Math.min (S1_code, S2_code);
if (S1_code!= s2_code)
return s1_code-s2_code;
}
return len1-len2;
}
public static string Getbegincharacter (String res)
{
String a = res;
String result = "";
for (int i = 0; i < a.length (); i++)
{
String current = a.substring (i, i + 1);
if (compare (current, "\u554a") < 0)
result = result + current;
Else
if (compare, "\u554a") >= 0 && Compare (current, "\u5ea7") <= 0)
if (compare (current, "\u531d") >= 0)
result = result + "Z";
Else
if (compare (current, "\u538b") >= 0)
result = result + "Y";
Else
if (compare (current, "\u6614") >= 0)
result = result + "X";
Else
if (compare (current, "\u6316") >= 0)
result = result + "W";
Else
if (compare (current, "\u584c") >= 0)
result = result + "T";
Else
if (compare (current, "\u6492") >= 0)
result = result + "s";
Else
if (compare (current, "\u7136") >= 0)
result = result + "R";
Else
if (compare (current, "\u671f") >= 0)
result = result + "q";
Else
if (compare (current, "\u556a") >= 0)
result = result + "P";
Else
if (compare (current, "\u54e6") >= 0)
result = result + "O";
Else
if (compare (current, "\u62ff") >= 0)
result = result + "n";
Else
if (compare (current, "\u5988") >= 0)
result = result + "M";
Else
if (compare (current, "\u5783") >= 0)
result = result + "L";
Else
if (compare (current, "\u5580") >= 0)
result = result + "K";
Else
if (compare (current, "\U51FB") > 0)
result = result + "J";
Else
if (compare (current, "\u54c8") >= 0)
result = result + "H";
Else
if (compare (current, "\u5676") >= 0)
result = result + "G";
Else
if (compare (current, "\u53d1") >= 0)
result = result + "F";
Else
if (compare (current, "\u86fe") >= 0)
result = result + "E";
Else
if (compare (current, "\u642d") >= 0)
result = result + "D";
Else
if (compare (current, "\u64e6") >= 0)
result = result + "C";
Else
if (compare (current, "\U82AD") >= 0)
result = result + "B";
Else
if (compare (current, "\u554a") >= 0)
result = result + "a";
}
return result;
}
public static string Getfirststr (String str)
{
char a = Str.charat (0);
Char aa[] = {
A
};
String sss = new string (AA);
if (Character.isdigit (aa[0]))
SSS = "Data";
Else
if (a >= ' a ' && a <= ' z ' | | A >= ' a ' && a <= ' z ')
SSS = "character";
Else
SSS = Getbegincharacter (SSS);
return SSS;
}
private static String _fromencode_ = "GBK";
private static String _toencode_ = "GBK";
}