Skip to content

Commit

Permalink
Filters::strLength() uses mbstring, iconv and then utf8_decode [Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 10, 2023
1 parent 599c3d1 commit 7ccfad0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Utils/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}


Expand Down

0 comments on commit 7ccfad0

Please sign in to comment.