function Iconv::strlen2
1 call to Iconv::strlen2()
- Iconv::iconv_strlen in vendor/
symfony/ polyfill-iconv/ Iconv.php
File
-
vendor/
symfony/ polyfill-iconv/ Iconv.php, line 457
Class
- Iconv
- iconv implementation in pure PHP, UTF-8 centric.
Namespace
Symfony\Polyfill\IconvCode
public static function strlen2($s, $encoding = null) {
if (null === $encoding) {
$encoding = self::$internalEncoding;
}
if (0 !== stripos($encoding, 'utf-8') && false === ($s = self::iconv($encoding, 'utf-8', $s))) {
return false;
}
$ulenMask = self::$ulenMask;
$i = 0;
$j = 0;
$len = \strlen($s);
while ($i < $len) {
$u = $s[$i] & "\xf0";
$i += $ulenMask[$u] ?? 1;
++$j;
}
return $j;
}