PHP handles mobile emoji expressions

WBOY
Release: 2016-07-29 09:08:57
Original
1578 people have browsed it

emoji is an emoticon, and is already a very popular expression on mobile phones.

Facing problems:

Inserting Emoji expressions and saving to the database gives an error:

SQLException: Incorrect string value: 'xF0x9Fx98x84' for column 'review' at row 1

UTF-8 The encoding may be two, three, or four bytes. Emoji expressions are 4 bytes, and Mysql's utf8 encoding can be up to 3 bytes, so the data cannot be inserted.

Solution:

1. Modify the character set in the data table structure to utf8mb4, but this change is relatively large and has a great impact on products that have been released online.

2. Filter it out, or replace it with UBB. This is the method I use in the project. Use reference https://github.com/newjueqi/converemojitostr

refer:

The starting point for emoji processing methods: http://blog.csdn.net/ugg/article/details/44225723

PHP-emoji conversion table: http://code.iamcal.com/php/emoji /


The above is an introduction to PHP's processing of mobile emoji expressions, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!