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