MB_DETECT_ENCODING:如何检测英语?

时间:2014-10-22 18:13:59

标签: php unicode

我的网站在中文,日文和俄罗斯人和其他人。

在MB_DETECT_ENCODING的帮助下,我能够检测到所有其他语言---但它没有正确检测到英语。

任何帮助表示赞赏!!!

$str = 'As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable. As of PHP 5.5 it is possible to array dereference an array literal.';


$lang = array('EUC-CN','EUC-JP','EUC-KR','EUC-TW','GB18030','SJIS','UCS-2','UCS-2BE','UCS-2LE','UTF-32','eucJP-win','EUC-JP-2004','SJIS-2004','CP932','JIS','ISO-2022-JP','ISO-8859-1','ISO-8859-2','ISO-8859-3','ISO-8859-4','ISO-8859-5','ISO-8859-6','ISO-8859-7','ISO-8859-8','ISO-8859-9','ISO-8859-10','ISO-8859-13','ISO-8859-14','ISO-8859-15','ISO-8859-16','EUC-CN','CP936','HZ','EUC-TW','BIG-5','EUC-KR','UHC','ISO-2022-KR','CP866','KOI8-R','KOI8-U','CP850','JIS-ms','ISO-2022-JP-2004','CP50220','CP50220raw','CP50221','CP50222');

//print_r($lang);

$enc = mb_detect_encoding($str,$lang);
    echo 'enc : ' . $enc . '<br><br>';

if(mb_detect_encoding($str,$lang) !='ASCII'){ 
    //return  iconv("gbk","utf-8",$str); 
    echo 'you cant spam here';
} 

0 个答案:

没有答案