Convert Unicode code to Chinese
public static string TOZHCN (string Unicode) {
StringBuffer GBK = new StringBuffer ();
String hex[] = Unicode.split ("\\\\u");
for (int i = 1; i < hex.length; i++) {//Note to start from 1 instead of 0. The first one is empty.
int data = Integer.parseint (Hex[i], 16); Converts 16 binary numbers to 10-binary data.
Gbk.append ((char) data); Cast to char type is our Chinese character.
}
System.out.println ("This is converted from Unicode to Chinese characters:" + gbk.tostring ());
return gbk.tostring ();
}
public static void Main (string[] args) {
TOZHCN ("\\u8bc1\\u4ef6\\u53f7\\u4e3a\\u7a7a");
}
--------------------------------------------------------------------------------------------------------------- --------------------------
//Convert string to Unicode code
public static string Tounicode (String zhstr) {
& nbsp; StringBuffer Unicode = new StringBuffer ();
for (int i = 0; i < zhstr.length (); i++) {
char c = zhstr.charat (i);
unicode.append ("\\u" + integer.tohexstring (c));
}
System.out.println (unicode.tostring ());
System.out.println (zhstr + "converted to Unicode code succeeded! ");
return unicode.tostring ();
}
public static void Main (string[] args) {
tounicode ("Hello");
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Unicode code and Chinese translation