PHP编码转换之iconv

来源:互联网 发布:教育软件上市公司 编辑:程序博客网 时间:2024/05/21 12:41
//是否包含function contain($str,$a){    $bool=false;    if(!isempt($a) && !isempt($str)){        $ad=strpos($str,$a);        if($ad>0||!is_bool($ad))$bool=true;    }    return $bool;}//返回字符串编码public function getencode($str){    $encode = mb_detect_encoding($str, array('ASCII','UTF-8','GB2312','GBK','BIG5'));    $encode = strtolower($encode);    return $encode;}//将$content转化为UTF-8$bm =  $this->getencode($content);if(!$this->contain($bm, 'utf')){    $content = @iconv($bm,'utf-8', $content);}