Database-level UTF-8
If you use PHP to operate to MySQL, sometimes even if you do all of the above, your string may still face the problem of storing it in a non-UTF-8 format in the database.
To ensure that your strings are used UTF-8 from PHP to MySQL, check that your database and data tables are set to UTF8MB4 character set and collation, and make sure that your PDO connection request also uses the UTF8MB4 character set. See the example code below, which is very important.
Please note that for full UTF-8 support, you must use UTF8MB4 instead of utf8! You'll find out why in the further reading.
Thank you for your reply, I found the detailed information on the Internet.
MYSQL:UTF8MB4 's Problem
MySQL utf8mb4 with emoji expression
Reply content:
Database-level UTF-8
If you use PHP to operate to MySQL, sometimes even if you do all of the above, your string may still face the problem of storing it in a non-UTF-8 format in the database.
To ensure that your strings are used UTF-8 from PHP to MySQL, check that your database and data tables are set to UTF8MB4 character set and collation, and make sure that your PDO connection request also uses the UTF8MB4 character set. See the example code below, which is very important.
Please note that for full UTF-8 support, you must use UTF8MB4 instead of utf8! You'll find out why in the further reading.
Thank you for your reply, I found the detailed information on the Internet.
MYSQL:UTF8MB4 's Problem
MySQL utf8mb4 with emoji expression
Emoji expression can only use UTF8MB4 storage, normal text only need 3byte storage, emoji need four
There are some Martian texts that can only be expressed in utf8mb4, and the UTF8 of MySQL implementation cannot
UTF8MB4 only supports emoji expression storage.