$text = "你好 hello 123"; //可以为收到的微信消息,可能包含二进制emoji表情字符串
$tmpStr = json_encode($text); //暴露出unicode
$tmpStr = preg_replace("#(\\\u(e|d)[0-9a-f]{3})#ie","addslashes('\\1')",$tmpStr); //将emoji的unicode留下,其他不动
$text = json_decode($tmpStr);
echo $text;//你好 \ue415 hello 123
原文地址:http://www.tuicool.com/articles/nMRRBf7