From c5bad6e1c65bd27c56baf5ab8c4955deb260f429 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 23 May 2012 16:15:06 +0000 Subject: handle triple (and more) encoding --- it.class | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/it.class b/it.class index 8ce1d65..eb7efb6 100644 --- a/it.class +++ b/it.class @@ -426,8 +426,8 @@ 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 (preg_match('/\xc3[\x82\x83]\xc2[\x82\x83\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(it::any2utf8(preg_replace_callback('/\xc3[\x82\x83]\xc2[\x82\x83\xbc\xa9\xa4\xb6\xa8\xa2\xa0\xb4\xaa\xa7\x84\xab\xae\x9c\xaf\x96\xb2\xbb\xb9\x9f]/', function($m) {return utf8_decode($m[0]);}, $value)), "$errmsg: double utf8-encoding. input=" . trim($value)); if ($error && $errmsg) it::error(array('title' => $error, 'skipfiles' => "it_html")); } -- cgit v1.2.3