1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-19 04:41:53 +02:00

Related to Issue #3741 - Incorrect encoding of a plugin language file could cause json encoding to fail.

This commit is contained in:
Cameron
2020-03-24 13:57:05 -07:00
parent 6c242729b9
commit 852ab5a32f
4 changed files with 64 additions and 10 deletions

View File

@@ -2120,7 +2120,36 @@ class e_parse extends e_parser
}
/**
* @param $mixed
* @return array|false|string
*/
public function toUTF8($mixed)
{
if(is_array($mixed))
{
foreach($mixed as $k => $v)
{
unset($mixed[$k]);
$mixed[$this->toUTF8($k)] = $this->toUTF8($v);
}
}
elseif(is_object($mixed))
{
$objVars = get_object_vars($mixed);
foreach($objVars as $key => $value)
{
$mixed->$key = $this->toUTF8($value);
}
}
elseif(is_string($mixed))
{
return iconv('UTF-8', 'UTF-8//IGNORE', utf8_encode($mixed));
}
return $mixed;
}
function toASCII($text)