Home > php教程 > PHP开发 > Solution to garbled emoji push

Solution to garbled emoji push

巴扎黑
Release: 2016-11-07 11:36:10
Original
2438 people have browsed it

If the push content contains emoji expressions, the following modifications need to be made
1 Mysql must use version 5.5.3 or above (if it cannot be upgraded, please save it in base64 and then transcode it when pushing)
2 Modify the table and push content table fields to utf8mb4_unicode_ci encoding format (no need to change the system my.cnf, no need to restart mysql)

If you use apnsphp to push, there may still be a problem that the emoji expression becomes ?:
Please find the getPayload method of Message.php , add "false &&" to the convert transcoding judgment to disable execution. Because this code will truncate some emoji expressions.

Java code

if (false && !defined('JSON_UNESCAPED_UNICODE') && function_exists('mb_convert_encoding')) {

$sJSON = preg_replace_callback(

           '~\\u([0-9a-f] {4})~i',

                       create_function('$aMatches', 'return mb_convert_encoding(pack("H*", $aMatches[1]), "UTF-8", "UTF-16");') ,

                                                                                                                                                                                                                       ​

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template