When WordPress is installed on a database using the utf8mb4 character set, everything works correctly.
However, issues arise when WordPress is installed on a database using the utf8 charset and an emoji character is present in any text field on the plugin’s settings page.
MySQL’s utf8 charset (an alias of utf8mb3) stores up to three bytes per character, while utf8mb4 can store up to 4 bytes characters as well. We need that fourth byte to support storing emoji characters.
To prevent the plugin from breaking when used on a database using the utf8 charset, we need to convert any emoji characters into their equivalent HTML entities and store them in the database instead.
When WordPress is installed on a database using the
utf8mb4
character set, everything works correctly.However, issues arise when WordPress is installed on a database using the
utf8
charset and an emoji character is present in any text field on the plugin’s settings page.MySQL’s
utf8
charset (an alias ofutf8mb3
) stores up to three bytes per character, whileutf8mb4
can store up to 4 bytes characters as well. We need that fourth byte to support storing emoji characters.To prevent the plugin from breaking when used on a database using the
utf8
charset, we need to convert any emoji characters into their equivalent HTML entities and store them in the database instead.