note 89944 added to function.mb-detect-encoding
| From: | prgss at bk dot ru | Date: | Mon, 30 Mar 2009 10:16:22 +0000 |
| Subject: | note 89944 added to function.mb-detect-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152601@lists.php.net to get a copy of this message | ||
Another light way to detect character encoding:
<?php
function detect_encoding($string) {
static $list = array('utf-8', 'windows-1251');
foreach ($list as $item) {
$sample = iconv($item, $item, $string);
if (md5($sample) == md5($string))
return $item;
}
return null;
}
?>
----
Server IP: 195.54.192.44
Probable Submitter: 85.21.148.200
----
Manual Page -- http://www.php.net/manual/en/function.mb-detect-encoding.php
Edit -- https://master.php.net/note/edit/89944
Del: integrated -- https://master.php.net/note/delete/89944/integrated
Del: useless -- https://master.php.net/note/delete/89944/useless
Del: bad code -- https://master.php.net/note/delete/89944/bad+code
Del: spam -- https://master.php.net/note/delete/89944/spam
Del: non-english -- https://master.php.net/note/delete/89944/non-english
Del: in docs -- https://master.php.net/note/delete/89944/in+docs
Del: other reasons-- https://master.php.net/note/delete/89944
Reject -- https://master.php.net/note/reject/89944
Search -- https://master.php.net/manage/user-notes.php