Answer the question
In order to leave comments, you need to log in
mysql encoding problems ERROR 1366 (HY000) at line 1: Incorrect string value. How to fix?
The error looks like this:
│ERROR 1366 (HY000) at line 1: Incorrect string value: '\xF0\x9F\x91\x91\xD0\x98...' for column 'name' at row 1
Answer the question
In order to leave comments, you need to log in
Firstly, uft8mb4 solves the problem entirely, just rechecked.
It all depends on how you insert those characters. Using prepared statements or manually calling mysqli_real_escape_string() (if it's PHP) you won't have any problems with these characters.
You can also remove characters, the first thing that comes to mind is to use the mb_* functions to determine the length of the string, then iterate character by character and get the character code. If the number is more than 2 bytes - delete.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question