Answer
Challenge: In one of my projects, users started entering emojis in text fields such as names, comments, and messages. Our MySQL database was using the utf8 character set, which only supports up to 3‑byte characters. Emojis require 4 bytes, so the application began throwing errors like “Incorrect string value” whenever an emoji was submitted.
Root Cause: MySQL’s utf8 encoding is not true UTF‑8. It cannot store 4‑byte characters such as emojis, certain symbols, and some multilingual characters.
Solution: I migrated the affected columns—and eventually the entire database—to utf8mb4, which fully supports 4‑byte Unicode characters.
Here’s the SQL change applied:
Code
Outcome: After the migration, all fields successfully accepted emojis and other 4‑byte characters. The application stopped throwing encoding errors, and user experience improved significantly.