Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the problem of mysql storing emoji emoticons?

Shulou Source: shulou.com Published: 2022-05-31 16:09:55 09月23日 Update

This article shows you what the problem of saving mysql into emoji emoticons is like, the content is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Test insert script

'\ xF0\ x9F\ x92\ x94' for column' name' at row 1

If you modify the character set online

Mysql > ALTER TABLE testtab CONVERT TO CHARACTER SET utf8mb4

Query OK, 0 rows affected (0.34 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > alter table testtab modify column `contents` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci

Query OK, 0 rows affected (0.36 sec)

Records: 0 Duplicates: 0 Warnings: 0

Run the insert script

View data

Mysql > select * from testtab

+-+

| | contents |

+-+

| | |

| | |

| | hello |

|? hello |-this one should be normal, four? It should be garbled.

+-+

Note:

This is right.

On the premise, the difference between utf8mb4 and utf8 is that utf8 only uses 3-bit bytecode to store data, while utf8mb4 uses 4-bit bytecode to store data.

Emoji emoji is a 4-bit bytecode escaped through the preceding paragraph, which itself is an unreadable character, so it will display "?" in the database client. .

The emoji emoji will be displayed where emoji is supported on the front end.

If you want to insert emoji emoticons in the context of utf8, you have to modify the configuration file and restart the database.

The above is the question of how mysql stores emoji emoticons. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Emoticons data bytes questions content characters that is skills databases knowledge scripts storage concise concise garbled premises front end place character set customer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux vpn MariaDB NVidia Docker