diff --git a/src/Utils/Strings.php b/src/Utils/Strings.php index 378ceee63..2a649ea7e 100644 --- a/src/Utils/Strings.php +++ b/src/Utils/Strings.php @@ -397,9 +397,11 @@ public static function findPrefix(array $strings): string */ public static function length(string $s): int { - return function_exists('mb_strlen') - ? mb_strlen($s, 'UTF-8') - : strlen(utf8_decode($s)); + return match (true) { + extension_loaded('mbstring') => mb_strlen($s, 'UTF-8'), + extension_loaded('iconv') => iconv_strlen($s, 'UTF-8'), + default => strlen(@utf8_decode($s)), // deprecated + }; }