public static function coding($str) { $charset = mb_detect_encoding($str, array('ASCII', 'GB2312', 'GBK', 'UTF-8')); if ($charset != 'UTF-8') { $str = iconv('UTF-8', $charset . '//IGNORE', $str); } return $str; }