diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -410,19 +410,27 @@ static function grep($pattern, $array, $p = array()) /** * Convert string to utf8 if it was not already utf-8 before. Also handles double encoding - * @param $value String to convert + * @param $value String or array to convert * @param $errmsg Error message to output if anything needed to be done * @return Same string in utf-8 encoding */ function any2utf8($value, $errmsg = "") { - if (grapheme_strlen($value) === null) - list($value, $error) = array(utf8_encode($value), utf8_encode("$errmsg: incorrect utf8-encoding. input=" . trim($value))); - if (preg_match('/\xc3\x83\xc2([\xbc\xa9\xa4\xb6\xa8\xa2\xa0\xb4\xaa\xa7\x84\xab\xae\x9c\xaf\x96\xb2\xbb\xb9\x9f])/', $value)) - list($value, $error) = array(preg_replace('/\xc3\x83\xc2([\xbc\xa9\xa4\xb6\xa8\xa2\xa0\xb4\xaa\xa7\x84\xab\xae\x9c\xaf\x96\xb2\xbb\xb9\x9f])/', "\xc3\$1", $value), utf8_encode("$errmsg: double utf8-encoding. input=" . trim($value))); - - if ($error && $errmsg) - it::error(array('title' => $error, 'skipfiles' => "it_html")); + if (is_array($value)) + { + foreach ($value as $idx => $v) + if (is_string($v) || is_array($v)) + $value[$idx] = self::any2utf8($v, $errmsg); + } + else + { + if (grapheme_strlen($value) === null) + list($value, $error) = array(utf8_encode($value), utf8_encode("$errmsg: incorrect utf8-encoding. input=" . trim($value))); + if (preg_match('/\xc3\x83\xc2([\xbc\xa9\xa4\xb6\xa8\xa2\xa0\xb4\xaa\xa7\x84\xab\xae\x9c\xaf\x96\xb2\xbb\xb9\x9f])/', $value)) + list($value, $error) = array(preg_replace('/\xc3\x83\xc2([\xbc\xa9\xa4\xb6\xa8\xa2\xa0\xb4\xaa\xa7\x84\xab\xae\x9c\xaf\x96\xb2\xbb\xb9\x9f])/', "\xc3\$1", $value), utf8_encode("$errmsg: double utf8-encoding. input=" . trim($value))); + if ($error && $errmsg) + it::error(array('title' => $error, 'skipfiles' => "it_html")); + } return $value; } |