Skip to content

Commit c211e67

Browse files
committed
Remove XFAIL from test cases for mb_strcut when used with JIS or ISO-2022-JP encoding
The documentation for mb_strcut states: mb_strcut( string $string, int $start, ?int $length = null, ?string $encoding = null ): string mb_strcut() extracts a substring from a string similarly to mb_substr(), but operates on bytes instead of characters. If the cut position happens to be between two bytes of a multi-byte character, the cut is performed starting from the first byte of that character. My understanding of the $length parameter for mb_strcut is that it specified the range of bytes to extract from $string, and that all characters encoded by those bytes should be included in the returned string, even if that means the returned string would be longer than $length bytes. This can happen either if 1) there is more than one way to encode the same character in $encoding, and one way requires more bytes than the other, or 2) $encoding uses escape sequences. However, discussion with users of mb_strcut indicates that many of them interpret $length as the maximum length of the *returned* string. This is also the historical behavior of the function. Hence, there is no need to modify the behavior of mb_strcut and then remove XFAIL from these test cases afterwards. We can keep the current behavior.
1 parent 3ab6e76 commit c211e67

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

ext/mbstring/tests/gh9535b.phpt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
--TEST--
2-
Output of mb_strcut covers requested range of bytes even when output contains ending escape sequences
2+
Test output of mb_strcut for text encodings which use escape sequences
33
--EXTENSIONS--
44
mbstring
55
--FILE--
66
<?php
7-
// The existing behavior of mb_strcut is wrong for these encodings, when they add an extra closing
8-
// escape sequence to a string which would otherwise end in a non-default conversion mode
9-
// See https://github.com/php/php-src/pull/9562 for details on the bug
10-
11-
// These tests were developed when fixing a different bug, but they don't pass because of
12-
// the bug involving the added closing escape sequences
13-
// When that bug is fixed, we can remove XFAIL (or combine this file with gh9535.phpt)
147

158
$encodings = [
169
'JIS',
@@ -78,16 +71,14 @@ foreach($encodings as $encoding) {
7871
}
7972

8073
?>
81-
--XFAIL--
82-
Discussion: https://github.com/php/php-src/pull/9562
8374
--EXPECTF--
84-
JIS: 宛如繁星般
85-
ISO-2022-JP: 宛如繁星般
75+
JIS: 宛如繁星
76+
ISO-2022-JP: 宛如繁星
8677
ISO-2022-JP-2004: 宛如繁星
8778

8879
JIS: 星のように月の
8980
ISO-2022-JP: 星のように月の
90-
ISO-2022-JP-2004: 星のように月の
81+
ISO-2022-JP-2004: 星のように月
9182

9283
JIS: あa
9384
ISO-2022-JP: あa

0 commit comments

Comments
 (0)