I have encountered a problem. To save the emoji expression output from iOS keyboard to MySQL, I know that blob + utf8 can be used. But now my table is too big to change the type. So I want to match the emoji, replace it, and save it. However, the iOS keyboard input emoji table... encountered a problem. To store the emoji output from the iOS keyboard to MySQL, I know that blob + utf8 can be used. But now my table is too big to change the type. So I want to match the emoji, replace it, and save it.
However, the emoji input on the iOS keyboard is not standard.
0xe001-
0xe537This is changed.
For example, for the first laugh expression, the standard emoji unicode is
0xe415The iOS keyboard outputs
0xd83dxde04Two.
I use preg_match () for matching.
preg_match('/\\x{d83d}\\x{de04}/', $str_with_emoji_emotion, $matches);var_dump($matches);
The output is NULL.
How can I match such emojis...
Supplement: I used preg_match ('/[\ x {0000}-\ x {FFFF}]/U', $ str_with_emoji_emotion, $ matches). None of them match... I suspect this is the problem of emojis. Continue to study... Continue solving...
Supplement 2: Get it done today, do the bin2hex transcoding http://jiajun.org/g/emoji_encoder.php
Reply content:
I have encountered a problem. To save the emoji expression output from iOS keyboard to MySQL, I know that blob + utf8 can be used. But now my table is too big to change the type. So I want to match the emoji, replace it, and save it.
However, the emoji input on the iOS keyboard is not standard.0xe001-0xe537This is changed.
For example, for the first laugh expression, the standard emoji unicode is0xe415The iOS keyboard outputs0xd83dxde04Two.
I use preg_match () for matching.
preg_match('/\\x{d83d}\\x{de04}/', $str_with_emoji_emotion, $matches);var_dump($matches);
The output is NULL.
How can I match such emojis...
Supplement: I used preg_match ('/[\ x {0000}-\ x {FFFF}]/U', $ str_with_emoji_emotion, $ matches). None of them match... I suspect this is the problem of emojis. Continue to study... Continue solving...
Supplement 2: Get it done today, do the bin2hex transcoding http://jiajun.org/g/emoji_encoder.php
Finished today, made the bin2hex transcode http://jiajun.org/g/emoji_encoder.php
Try this
preg_match('/\x{d83d}\x{de04}/u', $str_with_smail_emotion, $matches);
In fact, there is already an open-source Conversion Program.
Http://code.iamcal.com/php/emoji/
Https://github.com/iamcal/php-emoji
I hope this will help you.
Http://stackoverflow.com/questions/12807176/php-writing-a-simple-removeemoji-function #
Http://www.bubuko.com/infodetail-1022211.html reference this article
A formula is derived, which converts 0xd83d0xde04 to 1f604, while U + 1F604 is the uniform smiling face code.
In this article, JavaScript Functions are used. I extracted several key lines of code and converted them into PHP Code as follows:
$ H = 0xd83d; // high
$ L = 0xde04; // low
$ Code = ($ h-0xD800) x 0x400 + 0x10000 + $ l-0xDC00; // Conversion Algorithm
Echo "U +". strtoupper (dechex ($ code ));
// The echo result is U + 1F604.
In addition, @ seeyoup has already mentioned the conversion of different encoding methods.