Uuspider
Links: http://www.zhihu.com/question/23374078/answer/65352538
Source: Know
The Unicode character set you see is such an encoding table:
I 0049t 0074‘ 0027s 0073 0020知 77e5乎 4e4e日 65e5报 62a5
Each character corresponds to a hexadecimal number.
Computers only understand binary, so, strictly in Unicode (UCS-2), this should be stored in this way:
I 00000000 01001001t 00000000 01110100‘ 00000000 00100111s 00000000 01110011 00000000 00100000知 01110111 11100101乎 01001110 01001110日 01100101 11100101报 01100010 10100101
This string occupies a total of 18 bytes, but compared with the binary code in English, you can find that the first 9 bits of English are 0! Wasting, wasting your hard drive, wasting your traffic.
What to do?
UTF.
UTF-8 is doing this:
1. Single-byte characters, the first bit of byte is set to 0, for English text, the UTF-8 code occupies only one byte, and the ASCII code is identical;
2. N bytes of characters (n>1), the first n bits of a byte are set to 1, the n+1 bit is set to 0, the first two bits of the subsequent bytes are set to 10, the remaining slots of n bytes are populated with the character Unicode code, and the high level is filled with 0.
This creates the following UTF-8 marker bits:
0xxxxxxx
110xxxxx 10xxxxxx
1110xxxx 10xxxxxx 10xxxxxx
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
111110XX 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
... ...
As a result, "it's informed daily" has become:
I 01001001t 01110100‘ 00100111s 01110011 00100000知 11100111 10011111 10100101乎 11100100 10111001 10001110日 11100110 10010111 10100101报 11100110 10001010 10100101
Compared with the above scheme, the English is short, each Chinese character is used more than one byte. But the entire string only uses 17 bytes, which is a little bit shorter than the top 18.
What is UTF-8