mb_strlen
symfony/var-dumper
Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Get string length
mb_strlen
(
string $string
, ?
string $encoding
=
null
):
int
case
'string'
:
$this
->
type
=
self
::
TYPE_STRING
;
$this
->
class
=
preg_match
(
'//u'
,
$value
) ?
self
::
STRING_UTF8
:
self
::
STRING_BINARY
;
$this
->
cut
=
self
::
STRING_BINARY
===
$this
->
class
?
\strlen
(
$value
) :
mb_strlen
(
$value
,
'UTF-8'
);
$this
->
value
=
''
;
break;
}
Caster/CutStub.php
} else {
$stub
->
value
=
$v
;
}
} elseif (
0
<=
$maxString
&& isset(
$v
[
1
+ (
$maxString
>>
2
)]) &&
0
<
$cut
=
mb_strlen
(
$v
,
'UTF-8'
) -
$maxString
) {
$stub
= new
Stub
();
$stub
->
type
=
Stub
::
TYPE_STRING
;
$stub
->
class
=
Stub
::
STRING_UTF8
;
Cloner/VarCloner.php
$this
->
endValue
(
$cursor
);
} else {
$attr
+= [
'length'
=>
0
<=
$cut
?
mb_strlen
(
$str
,
'UTF-8'
) +
$cut
:
0
,
'binary'
=>
$bin
,
];
$str
=
$bin
&&
false
!==
strpos
(
$str
,
"\0"
) ? [
$str
] :
explode
(
"\n"
,
$str
);
Dumper/CliDumper.php
if (
$i
<
$m
) {
$str
.=
"\n"
;
}
if (
0
<
$this
->
maxStringWidth
&&
$this
->
maxStringWidth
<
$len
=
mb_strlen
(
$str
,
'UTF-8'
)) {
$str
=
mb_substr
(
$str
,
0
,
$this
->
maxStringWidth
,
'UTF-8'
);
$lineCut
=
$len
-
$this
->
maxStringWidth
;
}
Dumper/CliDumper.php