PHP将任意编码转换成UFT-8

风之吻 网站开发 478

PHP将任意编码转换成UFT-8-第1张图片-风享汇

  先找出字符串本身的编码,再转换为utf-8编码,话不多说 直接上代码:

function str_utf8 ($str = '') {$current_encode = mb_detect_encoding($str, array("ASCII","GB2312","GBK",'BIG5','UTF-8')); $encoded_str = mb_convert_encoding($str, 'UTF-8', $current_encode); return $encoded_str; }

PHP代码美化

标签: php

发布评论 0条评论)

还木有评论哦,快来抢沙发吧~