[String] add missing encoding when calling mb_ord()

This commit is contained in:
Nicolas Grekas 2020-01-14 18:54:59 +01:00
parent b4a63f925f
commit 759e20e6d3
2 changed files with 12 additions and 2 deletions

View File

@ -172,7 +172,17 @@ abstract class AbstractUnicodeString extends AbstractString
{
$str = $this->slice($offset, 1);
return '' === $str->string ? [] : array_map('mb_ord', preg_split('//u', $str->string, -1, PREG_SPLIT_NO_EMPTY));
if ('' === $str->string) {
return [];
}
$codePoints = [];
foreach (preg_split('//u', $str->string, -1, PREG_SPLIT_NO_EMPTY) as $c) {
$codePoints[] = mb_ord($c, 'UTF-8');
}
return $codePoints;
}
public function folded(bool $compat = true): parent

View File

@ -79,7 +79,7 @@ class CodePointString extends AbstractUnicodeString
{
$str = $offset ? $this->slice($offset, 1) : $this;
return '' === $str->string ? [] : [mb_ord($str->string)];
return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
}
public function endsWith($suffix): bool