專業團隊提供抓漏、防水、專治奇怪漏水
免費到府估價,絕對專業,歡迎來電
桃園拆除不論您搜尋任何資訊,都能讓你可以很方便地找資料
精準投放客群,搶業績最給力,速洽諮詢

首頁  •  j2h 論壇 • 程式設計討論     • 

[php] 將 文字 轉換成 &#xxxxx; UNICODE 碼

房東:小白
發表時間:2011-11-13


將中文字轉換成 &#xxxxx; UNICODE 碼, 主要的用途在於, 不用擔心有顯示不出來的文字.



引用來源



 










01 <?php










02 $str = '我';










03 /* 將 '我' 轉換成 '25105' 或 '&#25105;' */










04 // 使用 iconv










05 $unicode_html = base_convert(bin2hex(iconv('UTF-8', 'UCS-4', $str)), 16, 10); // 25105










06 // 使用 mb_convert_encoding










07 $unicode_html = base_convert(bin2hex(mb_convert_encoding($str, 'ucs-4', 'utf-8')), 16, 10); // 25105










08 // 補上 &#xxxxx;










09 $unicode_html = '&#' . base_convert(bin2hex(iconv("utf-8", "ucs-4", $str)), 16, 10) . ';'; // &#25105;










10 // 將 &#25105 轉回 '我'










11 $str = mb_convert_encoding($unicode_html, 'UTF-8', 'HTML-ENTITIES'); // '我', $unicode_html = '&#25105'










12 ?>




 


 


http://calos-tw.blogspot.com/2011/06/php-unicode.html





  • 贊助網站       

    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務
    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!



  •  共 0 人回應

    姓名:
    佈告內容:
    其他選項: