UTF-8 轉 BIG5 運用 mb_convert_encoding() 的處理方式

function utf8conv2charset($utf8str, $charset='big5',$encode='utf-8'){
mb_regex_encoding($charset); // 宣告 要進行 regex 的多位元編碼轉換格式 為 $charset
mb_substitute_character('long'); // 宣告 缺碼字改以U+16進位碼為標記取代
$utf8str = mb_convert_encoding($utf8str, $charset, $encode);
$utf8str = preg_replace('/U\+([0-9A-F]{4})/e', '"&#".intval("\\1",16).";"', $utf8str); //U+16進位碼標記轉換為UnicodeHTML碼
return $utf8str;
}

转载请注明出处:https://www.onexin.net/the-use-of-utf-8-transfer-big5-mb_convert_encoding-approach/

随机文章:

1、迅雷thunder://地址与普通url地址转换
https://www.onexin.net/thunder-thunder-address-and-general-url-address-translation/

2、php class类用法总结
https://www.onexin.net/php-class-class-usage-summary/

3、CentOS 5 上的 MRTG 图形化的流量分析报表快速入门
https://www.onexin.net/mrtg-on-centos-5-graphical-traffic-analysis-report-getting-started/

4、Wordpress首页和分页类标题SEO优化
https://www.onexin.net/wordpress-home-page-and-category-page-titles-seo-optimization/

5、SPL迭代器接口(六)—RecursiveIterator Interface
https://www.onexin.net/spl-recursiveiterator-interface/

Leave a Reply