From c92d857effaa5896fdcda5288bbfda047424a3c1 Mon Sep 17 00:00:00 2001 From: Louis-Arnaud Date: Sun, 16 Aug 2026 19:46:09 +0200 Subject: [PATCH] ext/mbstring: fix the version of the character index change, it shipped in 8.3.2 The mb_substr changelog dated the character index change to 8.4.0, which is what UPGRADING says, but the commit landed on the PHP-8.3 branch and the first release containing it is 8.3.2. Verified by bisecting the official images: mb_substr("A\x85\xABB", 1, 1, "SJIS-mac") returns the whole SJIS unit on 8.3.1 and a single codepoint from 8.3.2 onwards, and mb_substr("\xf0start", 1, 5) likewise flips at the same boundary. - mb-substr.xml: merge the two rows into a single 8.3.2 entry, both described the same commit - mb-strstr.xml: add the same entry, mb_strstr is affected too and had no changelog for it - migration84/incompatible.xml: state the actual version, the change is still relevant to anyone upgrading from 8.3.0 or 8.3.1 - use the encoding name the manual and php-src actually use, SJIS-mac, and drop the "around 40" figure, an exhaustive scan of the two byte SJIS-mac units gives 56 - mb-substr.xml: take the seealso simplelist out of its para - book.xml: the Unicode table version is not a standing fact, 8.5.0 updated the tables to Unicode 17.0, so name both releases Sources - php-src ec348a12d11 ("Character indices used by mb_strpos and mb_substr have same meaning, even on invalid strings", 2023-12-06), first tag php-8.3.2 - php-src 3afb96184e7 ("ext/mbstring: Update to Unicode 16"), first tag php-8.4.0RC1 - php-src edc26712278 ("ext/mbstring: Update to Unicode 17.0"), PHP-8.5 --- appendices/migration84/incompatible.xml | 16 ++++++++-------- reference/mbstring/book.xml | 19 ++++++++++++------- reference/mbstring/functions/mb-strstr.xml | 10 ++++++++++ reference/mbstring/functions/mb-substr.xml | 17 ++++++++++------- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/appendices/migration84/incompatible.xml b/appendices/migration84/incompatible.xml index 947b9dd167f5..f1251351dc94 100644 --- a/appendices/migration84/incompatible.xml +++ b/appendices/migration84/incompatible.xml @@ -517,19 +517,19 @@ MBString - On invalid strings (those with encoding errors), - mb_substr now interprets character indices in the same - manner as most other mbstring functions. + As of PHP 8.3.2, on invalid strings (those with encoding errors), + mb_substr and mb_strstr interpret + character indices in the same manner as most other mbstring functions. This means that character indices returned by mb_strpos can be passed to mb_substr. - For SJIS-Mac (MacJapanese) strings, character indices passed to - mb_substr now refer to the indices of the Unicode - codepoints which are produced when the string is converted to Unicode. - This is significant because around 40 SJIS-Mac characters convert to a - sequence of multiple Unicode codepoints. + For SJIS-mac (MacJapanese) strings, those character + indices refer to the indices of the Unicode codepoints which are produced + when the string is converted to Unicode, which differ from the character + indices for the SJIS-mac characters that convert to a + sequence of several codepoints. diff --git a/reference/mbstring/book.xml b/reference/mbstring/book.xml index 3de34d4edc8a..046c4e5031f8 100644 --- a/reference/mbstring/book.xml +++ b/reference/mbstring/book.xml @@ -28,14 +28,19 @@ the multibyte character and ends up with a corrupted garbage string that most likely loses its original meaning. - - mbstring provides multibyte specific string functions - that help you deal with multibyte encodings in PHP. In addition to that, - mbstring handles character encoding conversion between - the possible encoding pairs. mbstring is designed to - handle Unicode-based encodings such as UTF-8 and UCS-2 and many + + mbstring provides multibyte specific string functions + that help you deal with multibyte encodings in PHP. In addition to that, + mbstring handles character encoding conversion between + the possible encoding pairs. mbstring is designed to + handle Unicode-based encodings such as UTF-8 and UCS-2 and many single-byte encodings for convenience (listed in Supported Character Encodings). - + + + The Unicode data tables used by mbstring have been + updated to Unicode 16.0 as of PHP 8.4.0, and to Unicode 17.0 as of + PHP 8.5.0. + diff --git a/reference/mbstring/functions/mb-strstr.xml b/reference/mbstring/functions/mb-strstr.xml index 96ec7d64252c..eb61d8e83ec2 100644 --- a/reference/mbstring/functions/mb-strstr.xml +++ b/reference/mbstring/functions/mb-strstr.xml @@ -84,6 +84,16 @@ + + 8.3.2 + + On invalid strings (those with encoding errors) and on + SJIS-mac (MacJapanese) strings, the portion of + haystack returned when + before_needle is &true; is now determined from + the same character indices as the other mbstring functions. + + &mbstring.changelog.needle-empty; &mbstring.changelog.encoding-nullable; diff --git a/reference/mbstring/functions/mb-substr.xml b/reference/mbstring/functions/mb-substr.xml index 7f769da05fdb..4fc252f73e6c 100644 --- a/reference/mbstring/functions/mb-substr.xml +++ b/reference/mbstring/functions/mb-substr.xml @@ -98,12 +98,17 @@ - 8.4.0 + 8.3.2 On invalid strings (those with encoding errors), character indices are now interpreted in the same manner as most other mbstring functions. This means that character indices returned by mb_strpos can be passed directly. + For SJIS-mac (MacJapanese) strings, character + indices now refer to the indices of the Unicode codepoints produced + when the string is converted to Unicode, which differ from the + character indices for the SJIS-mac characters that + convert to a sequence of several codepoints. &mbstring.changelog.encoding-nullable; @@ -114,12 +119,10 @@ &reftitle.seealso; - - - mb_strcut - mb_internal_encoding - - + + mb_strcut + mb_internal_encoding +