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、增加网站反向链接的10种方法
https://www.onexin.net/increase-website-backlinks-10-kinds-of-methods/

2、Magento整合Ucenter实战百万会员篇
https://www.onexin.net/magento-integration-ucenter-real-million-members-articles/

3、MySQL中my.cnf配置文件及参数介绍
https://www.onexin.net/mysql-my-cnf-configuration-files-and-parameters-introduced/

4、Supesite模板制作官方视频教程
https://www.onexin.net/supesite-templates-to-create-the-official-video-tutorials/

5、[个人潜能2B]成功的科学条件神经联想之调整(NAC)
https://www.onexin.net/personal-potentials-2b-conditions-for-the-success-of-the-scientific-association-of-neural-adjustment-nac/

Leave a Reply