The emoji of common problem handling

Source: Internet
Author: User

The so-called emoji is a Unicode location\u1F601-\u1F64FThe character of the segment. This obviously exceeds the encoding range of the currently used UTF-8 character set.\u0000-\uFFFF。 Emoji expression with the popularity and support of iOS is becoming more and more common. Here are a few common emoji: So what is the impact of emoji character emoticons on our usual development operations? The most common problem is when you put him in the MySQL database. In general, the default character set for MySQL databases is configured to be UTF-8 (three bytes), and UTF8MB4 is supported after 5.5, and few DBAs actively change the system default character set to UTF8MB4. So the problem is, when we put a character that requires 4 bytes of UTF-8 encoding to be stored in the database, we get an error:ERROR 1366: Incorrect string value: ‘\xF0\x9D\x8C\x86‘ for column。 If you read the above explanation carefully, then this error is not ugly to understand. We tried to insert a string of bytes into a column, and the first byte of the string bytes was\xF0This means that this is a four-byte UTF-8 encoding. However, when the MySQL table and column character set are configured as UTF-8, it is not possible to store such characters, so the error is reported. So how do we solve this situation? There are two ways: upgrade MySQL to 5.6 or later, and switch the table character set to UTF8MB4. The second method is to filter the content before depositing it into the database, replacing the emoji character with a special text encoding and then depositing it into the database. This special text encoding is then converted to emoji display from the database or the front-end display. The second method we assume is to use-*-1F601-*-To replace the 4-byte emoji, then implement the Python code to see the answers on StackOverflow

The emoji of common problem handling

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.