summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2026-05-22 14:18:10 +0200
committerUrban Müller2026-05-22 14:18:10 +0200
commitb1202bc02df27381c63c36085dd2fb2af028b25f (patch)
treebe75ea2ca8764323022f3498e7fc4cd156d017f7
parentc3c521bd4b5e145b0bd7cb37cbed40a4544e17bb (diff)
downloaditools-master.tar.gz
itools-master.tar.bz2
itools-master.zip
use (faster) proper func to check for valid utf8HEADmaster
-rw-r--r--it.class2
1 files changed, 1 insertions, 1 deletions
diff --git a/it.class b/it.class
index 2aebd27..6ed5425 100644
--- a/it.class
+++ b/it.class
@@ -601,7 +601,7 @@ static function any2utf8($value, $errprefix = "")
}
else if (is_string($value))
{
- if (!is_int(grapheme_strlen($value)))
+ if (!mb_check_encoding($value, "UTF-8"))
list($value, $error) = array(it::utf8_encode($value), it::utf8_encode("incorrect utf8-encoding. input=$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 it::utf8_decode($m[0]);}, $value)), $errprefix ? "double utf8-encoding. input=$value" : "");