From 759e20e6d332d8a79d2608db9ebcb30a325cd019 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 14 Jan 2020 18:54:59 +0100 Subject: [PATCH] [String] add missing encoding when calling mb_ord() --- .../Component/String/AbstractUnicodeString.php | 12 +++++++++++- src/Symfony/Component/String/CodePointString.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index 19ad5e8939d95..bc3e05cd6f10c 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -172,7 +172,17 @@ public function codePointsAt(int $offset): array { $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 diff --git a/src/Symfony/Component/String/CodePointString.php b/src/Symfony/Component/String/CodePointString.php index 8a729bb9e1623..d1ac91570181d 100644 --- a/src/Symfony/Component/String/CodePointString.php +++ b/src/Symfony/Component/String/CodePointString.php @@ -79,7 +79,7 @@ public function codePointsAt(int $offset): array { $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 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