將中文字轉換成 &#xxxxx; UNICODE 碼, 主要的用途在於, 不用擔心有顯示不出來的文字.
引用來源
03 |
/* 將 \'我\' 轉換成 \'25105\' 或 \'我\' */ |
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 |
09 |
$unicode_html = \'&#\' . base_convert(bin2hex(iconv("utf-8", "ucs-4", $str)), 16, 10) . \';\'; // 我 |
11 |
$str = mb_convert_encoding($unicode_html, \'UTF-8\', \'HTML-ENTITIES\'); // \'我\', $unicode_html = \'我\' |
http://calos-tw.blogspot.com/2011/06/php-unicode.html
|