Skip to content

Commit

Permalink
Helprs::utf8Length() 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 3a6fb90 commit fc1dfa7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Tracy/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,11 @@ private static function utf8Ord(string $c): int
/** @internal */
public static function utf8Length(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 fc1dfa7

Please sign in to comment.