mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-23 22:01:47 +01:00
detect if function iconv exists before trying to use it while detecting charset
This commit is contained in:
parent
862e07d9a3
commit
e8349f3daa
@ -3133,11 +3133,13 @@
|
|||||||
*/
|
*/
|
||||||
static function detect_encoding($string) {
|
static function detect_encoding($string) {
|
||||||
static $list = array('utf-8', 'iso-8859-1', 'windows-1251'); // list may be extended
|
static $list = array('utf-8', 'iso-8859-1', 'windows-1251'); // list may be extended
|
||||||
|
if (function_exists('iconv'))
|
||||||
foreach ($list as $item) {
|
{
|
||||||
$sample = iconv($item, $item, $string);
|
foreach ($list as $item) {
|
||||||
if (md5($sample) == md5($string))
|
$sample = iconv($item, $item, $string);
|
||||||
return $item;
|
if (md5($sample) == md5($string))
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false; // we may choose to return iso-8859-1 as default at some point
|
return false; // we may choose to return iso-8859-1 as default at some point
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user