Skip to content

Commit 978261d

Browse files
[String] add missing encoding when calling mb_ord()
1 parent 4a1bd8a commit 978261d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

AbstractUnicodeString.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,17 @@ public function codePointsAt(int $offset): array
172172
{
173173
$str = $this->slice($offset, 1);
174174

175-
return '' === $str->string ? [] : array_map('mb_ord', preg_split('//u', $str->string, -1, PREG_SPLIT_NO_EMPTY));
175+
if ('' === $str->string) {
176+
return [];
177+
}
178+
179+
$codePoints = [];
180+
181+
foreach (preg_split('//u', $str->string, -1, PREG_SPLIT_NO_EMPTY) as $c) {
182+
$codePoints[] = mb_ord($c, 'UTF-8');
183+
}
184+
185+
return $codePoints;
176186
}
177187

178188
public function folded(bool $compat = true): parent

CodePointString.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function codePointsAt(int $offset): array
7979
{
8080
$str = $offset ? $this->slice($offset, 1) : $this;
8181

82-
return '' === $str->string ? [] : [mb_ord($str->string)];
82+
return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
8383
}
8484

8585
public function endsWith($suffix): bool

0 commit comments

Comments
 (0)