Skip to content

Commit 0735432

Browse files
committed
Use mb_strlen(8bit) to get length in bytes
The strlen might be messed up by mbstring overloading. Signed-off-by: Michal Čihař <michal@cihar.com>
1 parent 4aadd25 commit 0735432

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/UtfString.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ public function __construct($str)
7676
$this->str = $str;
7777
$this->byteIdx = 0;
7878
$this->charIdx = 0;
79-
// TODO: `strlen($str)` might return a wrong length when function
80-
// overloading is enabled.
81-
// https://php.net/manual/ro/mbstring.overload.php
82-
$this->byteLen = strlen($str);
79+
$this->byteLen = mb_strlen($str, '8bit');
8380
$this->charLen = mb_strlen($str, 'UTF-8');
8481
}
8582

0 commit comments

Comments
 (0)