bug #35339 [String] add missing encoding when calling mb_ord() (nicolas-grekas)
This PR was merged into the 5.0 branch.
Discussion
----------
[String] add missing encoding when calling mb_ord()
| Q | A
| ------------- | ---
| Branch? | 5.0
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Commits
-------
759e20e6d3
[String] add missing encoding when calling mb_ord()
This commit is contained in:
commit
0dcf2fcdf5
@ -172,7 +172,17 @@ abstract class AbstractUnicodeString extends AbstractString
|
|||||||
{
|
{
|
||||||
$str = $this->slice($offset, 1);
|
$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
|
public function folded(bool $compat = true): parent
|
||||||
|
@ -79,7 +79,7 @@ class CodePointString extends AbstractUnicodeString
|
|||||||
{
|
{
|
||||||
$str = $offset ? $this->slice($offset, 1) : $this;
|
$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
|
public function endsWith($suffix): bool
|
||||||
|
Reference in New Issue
Block a user