Mobile input allows input expression, the expression is actually UTF-16 encoding, in the database storage will be lost, currently if the database Loadline code modified to UTF8MB4 can also be saved.
If you do not want to modify the others, you can convert these emoji to the HTML character entity save.
The code is as follows:
Function utf16_to_entities () { $content = mb_convert_encoding ($content, ' utf-16 '); $bin = bin2hex ($content); $arr = str_split ($bin, 4); $l = count ($arr); $str = '; for ($n = 0; $n < $l; $n +) { if (Isset ($arr [$n + 1]) && (' 0x ' . $arr [$n] >= 0xd800 && ' 0x ' . $arr [$n] <= 0xdbff && ' 0x ' . $arr [$n + 1] >= 0xdc00 && ' 0x ' . $arr [$n + 1] <= 0xdfff) { $H = ' 0x ' . $arr [$n]; $L = ' 0x ' . $arr [$n + 1]; $code = ($H - 0xd800) * 0x400 + 0x10000 + $L - 0xDC00; $str .= ' . $code . '; '; $n ++; } else { $ Str.=mb_convert_encoding (Hex2bin ($arr [$n]), ' utf-8 ', ' utf-16 '); } } return $str;}
Note: Here the word characters is utf-8 if the code is working with a format that GBK modifies itself.
This article is from the "gangbusters" blog, make sure to keep this source http://php2012web.blog.51cto.com/5585213/1863313
PHP convert emoji emoticons to HTML character entities