免費提供紙箱及拆裝、24H全省服務
合約保障、提供您平價又專業的搬家服務
法拍精做高難度防水抓漏/壁癌/油漆等工程
責任施工、合約保固!

首頁  •  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 人回應

    姓名:
    佈告內容: