We used Unicode to welcome the use of emoji in future projects. then, the problem arises, and the backend MySQL database cannot store emoji characters. Emoji is a subset of the Unicode character set. Unicode should be widely used. how can this problem be solved? This should start from scratch. Unicode is used to solve the unified encoding of global characters. with this character set, it can accommodate the characters and special symbols of all languages around the world. It corresponds to the national standard encoding such as GB-2312 or GBK, used to encode Chinese characters. GB-2312 coding is getting fewer and fewer. But Unicode is only binary encoding, character conversion and transmission still need to define the exchange code, this is usually called UTF-8, UTF-16, UTF-32 ...... It is used to encode the character representation of Unicode characters in binary format, the most commonly used is the UTF-8. Again, UTF-8, it is variable-length encoding, uses 1-6 bytes to encode a Unicode character, for example, Ascii code uses 1 byte, Chinese characters usually use 3 bytes, emoji is 4 bytes. This is the problem. In the early days, MySQL supported UTF8 encoding and storage of three bytes, so it was always safe. However, with the development of Unicode, emoji is widely used. many characters must be UTF-8 encoded with four bytes for representation, as a result, these characters are truncated or garbled into the MySQL database. The solution is to upgrade MySQL to 5.5.4 or above, and upgrade the character set to utf8mb4. Today, Unicode announced the new 7.0 standard, with at least 2834 characters added, including new emoji emoticons. we will be staring at Unicode in the future and handling problems with a global perspective, there will be less trouble in the future.
-- Welcome to reprint, please indicate the source of the original http://blog.csdn.net/caowenbin ---- welcome to pay attention to "Cao Wenbin software thinking", to jointly discuss the software life --
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.