Skip to content

Commit 6930ef5

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix mb_strlen is wrong length for CP932 when 0x80.
2 parents c6655fb + c33589e commit 6930ef5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cjk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8050,7 +8050,7 @@ const mbfl_encoding mbfl_encoding_sjis2004 = {
80508050
* 0x7E will go to 0x7E when converting Shift-JIS to CP932.
80518051
*/
80528052

8053-
static const unsigned char mblen_table_sjiswin[] = { /* 0x80-0x9F,0xE0-0xFF */
8053+
static const unsigned char mblen_table_sjiswin[] = { /* 0x81-0x9F,0xE0-0xFF */
80548054
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80558055
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80568056
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -8059,7 +8059,7 @@ static const unsigned char mblen_table_sjiswin[] = { /* 0x80-0x9F,0xE0-0xFF */
80598059
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80608060
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80618061
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8062-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8062+
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80638063
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80648064
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80658065
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

ext/mbstring/tests/mb_strlen.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ print "-- Testing illegal bytes 0x80,0xFD-FF --\n";
3535
print mb_strlen("\x80\xA1", 'SJIS') . "\n";
3636
print mb_strlen("abc\xFD\xFE\xFF", 'SJIS') . "\n";
3737

38+
echo "== CP932 ==\n";
39+
print mb_strlen("\x80\xA1", "CP932") . "\n";
40+
// 0xFD, 0xFE, 0xFF is reserved.
41+
print mb_strlen("abc\xFD\xFE\xFF", 'CP932') . "\n";
42+
print mb_strlen("\x80\xA1", "SJIS-win") . "\n";
43+
print mb_strlen("abc\xFD\xFE\xFF", 'SJIS-win') . "\n";
44+
3845
echo "== MacJapanese ==\n";
3946
print mb_strlen("\x80\xA1", 'MacJapanese') . "\n";
4047
print mb_strlen("abc\xFD\xFE\xFF", 'MacJapanese') . "\n";
@@ -107,6 +114,11 @@ try {
107114
-- Testing illegal bytes 0x80,0xFD-FF --
108115
2
109116
6
117+
== CP932 ==
118+
2
119+
6
120+
2
121+
6
110122
== MacJapanese ==
111123
2
112124
7

0 commit comments

Comments
 (0)