微信emoji表情及输入法自带表情存储与显示

来源:互联网 发布:c语言函数的定义 编辑:程序博客网 时间:2024/04/29 22:29
    //utf8mb4表情转换,用于存储    function textEncode($text){        $txtContent=json_encode($text);        //\\\u[0-9a-f]{4}        $txtContent=preg_replace_callback ('#(\\\u263a|\\\u2728|\\\u2b50|\\\u2753|\\\u270a|\\\u261d|\\\u2757|\\\ud[0-9a-f]{3}\\\ud[0-9a-f]{3})#',function($matches){ return  addslashes($matches[1]);}, $txtContent);        $txtContent=json_decode($txtContent);        return $txtContent;    }    //表情反转,用于显示    function textDecode($text){        $txtContent=json_encode($text);        $txtContent=preg_replace_callback ('#(\\\u263a|\\\u2728|\\\u2b50|\\\u2753|\\\u270a|\\\u261d|\\\u2757|\\\ud[0-9a-f]{3})#',function($matches){ print_r($matches);return  stripslashes($matches[1]);}, $txtContent);        $txtContent=json_decode($txtContent);        return $txtContent;    }$table = '                                             
0 0
原创粉丝点击