Skip to content

Commit

Permalink
Filters::strLength() uses mbstring, iconv and then utf8_decode
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 10, 2023
1 parent e24c412 commit bbc6174
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Latte/Essential/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,11 @@ public static function length(array|\Countable|\Traversable|string $val): int

private static function strLength(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 bbc6174

Please sign in to comment.