Skip to content

Commit 759e20e

Browse files
[String] add missing encoding when calling mb_ord()
1 parent b4a63f9 commit 759e20e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 11 additions & 1 deletion
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

src/Symfony/Component/String/CodePointString.php

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy