I am inserting mysql into the database. When trying to paste
I get the following error:Incorrect string value: '\xF0\x9F\x87\xB7\xF0\x9F...' for column 'field_4' at row 1
I thought I understood this error by simply changing the column encoding to utf8mb4 and tested, but recently this error has appeared again. I am using php to parse a string and run the following function before pasting ...
function strip_emoji($subject) {
if (is_array($subject)) {
foreach ($subject as &$value) $value = $this->strip_emoji($value);
return $subject;
} else {
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clean_text = preg_replace($regexEmoticons, '', $subject);
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
$clean_text = preg_replace($regexSymbols, '', $clean_text);
$regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
$clean_text = preg_replace($regexTransport, '', $clean_text);
return
}
There are several similar questions, but I still have these errors. Any further recommendations on how to prevent this error? I understand that this is a character / sprite unoode from emoji, but not sure how to deal with it.
source
share