According to the supplementary question of the previous article http://blog.csdn.net/fancylovejava/article/details/10142391
With the understanding of the previous article, I have probably learned about the Unicode encoding format.
ANSI: The inner code range of the Chinese character area is high byte from B0-f7, low byte from A1-fe
Unicode: The Unicode encoding range for Chinese characters is \u4e00-\u9fa5 \uf900-\ufa2d, which is not a Chinese character if not within this range.
The problem with the program now is that when the server sends Chinese to the Android client, the Android client gets the string and then displays it to the interface, but the result is
Unicode encoding Format & #24320;& #22987;& #20817;& #22870; So, it's going to change.
There are relevant website tools for converting Unicode encoding and ASICC encoding, http://tool.chinaz.com/Tools/Unicode.aspx
The JDK has a tool that also provides the conversion, is Native2ascii.exe, under the bin directory, directly points to enter the Chinese to be possible
There is a good article to introduce http://sailinglee.iteye.com/blog/430568
But we have to be in the program of this & #24320, translated into Chinese ah ~ ~ ~
String a= "Start Redemption";
System.out.println (A.codepointat (0));
This is printed with the word "open" & #24320; the digit part of the Unicode code 24320
System.out.println ((char) 24320);
The print is to convert a number to a char type, and this char type is a Chinese character that represents the Unicode code,
Print out the result is: Open
With this, we can convert Unicode to Chinese.
There's also an article that's good, turn around. http://blog.csdn.net/ocean20/article/details/6743385 Description char This character type in Java
Char in Java takes up several bytes
1: "Byte" is byte, "bit" is bit;
2:1 byte = 8 bit;
Char is 2 bytes in Java. Java uses a unicode,2 byte (16-bit) to represent one character.
The example code is as follows:
[Java] View plain copy public class test { public static void main (String[] args) { String str= "Medium"; char x = ' Zhong '; byte[] bytes=null; byte[] bytes1=null; try { bytes = str.getbytes ("Utf-8"); bytes1 = chartobyte (x); } catch (unsupportedencodingexception e) { // todo auto-generated catch block e.printstacktrace (); } System.out.println ("bytes size:" +bytes.length); System.out.println ("Bytes1 size:" +bytes1.length); } public static byte[] chartobyte (char c) { byte[] b = new byte[2]; b[0] = (Byte) (C & 0XFF00) >> 8); b[1] = (byte) (c & 0xfF); return b; } }
Run Result:
Bytes Size: 3
Bytes1 Size: 2
Java is used to represent characters in Unicode, and Unicode for the Chinese character "medium" is 2 bytes.
The String.getbytes (encoding) method is to get a byte array representation of the specified encoding,
Typically, the gbk/gb2312 is 2 bytes, and the Utf-8 is 3 bytes .
If encoding is not specified, the system default encoding is taken.