(1)php微信開發之符號表情

程式碼修行者發表於2014-05-29

再看 柳峰老師 http://blog.csdn.net/lyq8479/article/details/9393097 的微信博文的是後發現php傳送的原樣輸出


由於 php 對Unicode的支援不是好

java,c# 中 不需要轉換,直接傳送給微信就可以轉換成符號

function unicode2utf8_2($str){	//關於unicode編碼轉化的第二個函式,用於顯示emoji表情
$str = '{"result_str":"'.$str.'"}';	//組合成json格式
$strarray = json_decode($str,true);	//json轉換為陣列,利用 JSON 對 \uXXXX 的支援來把轉義符恢復為 Unicode 字元(by 樑海)
return $strarray['result_str'];
}
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType,"自行車".unicode2utf8_2("\ue136")." 男人".unicode2utf8_2("\ue138")." 錢袋".unicode2utf8_2("\ue12f")." 情侶".unicode2utf8_2("\ue428")." 公共汽車".unicode2utf8_2("\ue159"));
echo $resultStr;


相關文章