In this paper, the realization method of realizing the conversion of Chinese characters into Unicode and the 16 Chinese characters by Java is described. Share to everyone for your reference. The implementation methods are as follows:
First, Chinese characters to Unicode
Copy Code code as follows:
public static string Tounicode (string s)
{
String as[] = new String[s.length ()];
String S1 = "";
for (int i = 0; i < s.length (); i++)
{
As[i] = integer.tohexstring (S.charat (i) & 0xFFFF);
S1 = S1 + as[i]+ "T";
}
return s1;
}
Two, the Chinese character turns 16 to enter the system
Copy Code code as follows:
public static string Tochinesehex (string s)
{
String SS = S;
byte[] bt = Ss.getbytes ();
String S1 = "";
for (int i = 0; i < bt.length; i++)
{
String TempStr = integer.tohexstring (Bt[i]);
if (Tempstr.length () > 2)
TempStr = tempstr.substring (Tempstr.length ()-2);
S1 = S1 + tempstr + "";
}
return S1.touppercase ();
}
I hope this article will help you with your Java programming.