note 111747 added to function.mb-detect-encoding
| From: | bmrkbyet at web dot de | Date: | Sun, 24 Mar 2013 14:04:38 +0000 |
| Subject: | note 111747 added to function.mb-detect-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194188@lists.php.net to get a copy of this message | ||
a) if the FUNCTION mb_detect_encoding is not available:
### mb_detect_encoding ... iconv ###
<?php
// -------------------------------------------
if(!function_exists('mb_detect_encoding')) {
function mb_detect_encoding($string, $enc=null) {
static $list = array('utf-8', 'iso-8859-1', 'windows-1251');
foreach ($list as $item) {
$sample = iconv($item, $item, $string);
if (md5($sample) == md5($string)) {
if ($enc == $item) { return true; } else { return $item; }
}
}
return null;
}
}
// -------------------------------------------
?>
b) if the FUNCTION mb_convert_encoding is not available:
### mb_convert_encoding ... iconv ###
<?php
// -------------------------------------------
if(!function_exists('mb_convert_encoding')) {
function mb_convert_encoding($string, $target_encoding, $source_encoding) {
$string = iconv($source_encoding, $target_encoding, $string);
return $string;
}
}
// -------------------------------------------
?>
----
Server IP: 69.147.83.199
Probable Submitter: 188.193.188.71
----
Manual Page -- http://php.net/manual/en/function.mb-detect-encoding.php
Edit -- https://master.php.net/note/edit/111747
Del: integrated -- https://master.php.net/note/delete/111747/integrated
Del: useless -- https://master.php.net/note/delete/111747/useless
Del: bad code -- https://master.php.net/note/delete/111747/bad+code
Del: spam -- https://master.php.net/note/delete/111747/spam
Del: non-english -- https://master.php.net/note/delete/111747/non-english
Del: in docs -- https://master.php.net/note/delete/111747/in+docs
Del: other reasons-- https://master.php.net/note/delete/111747
Reject -- https://master.php.net/note/reject/111747
Search -- https://master.php.net/manage/user-notes.php