Skip to content

Commit c50172e

Browse files
youkidearitaialexdowad
authored andcommitted
Fix mb_strlen is wrong length for CP932 when 0x80.
1 parent b374ec3 commit c50172e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cp932.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
static int mbfl_filt_conv_cp932_wchar_flush(mbfl_convert_filter *filter);
6767

68-
static const unsigned char mblen_table_sjis[] = { /* 0x80-0x9f,0xE0-0xFF */
68+
static const unsigned char mblen_table_sjis[] = { /* 0x81-0x9f,0xE0-0xFF */
6969
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7070
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7171
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -74,7 +74,7 @@ static const unsigned char mblen_table_sjis[] = { /* 0x80-0x9f,0xE0-0xFF */
7474
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7575
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7676
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
77-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
77+
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
7878
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
7979
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8080
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

ext/mbstring/tests/mb_strlen.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ 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+
3843
echo "== MacJapanese ==\n";
3944
print mb_strlen("\x80\xA1", 'MacJapanese') . "\n";
4045
print mb_strlen("abc\xFD\xFE\xFF", 'MacJapanese') . "\n";
@@ -91,6 +96,9 @@ try {
9196
-- Testing illegal bytes 0x80,0xFD-FF --
9297
2
9398
6
99+
== CP932 ==
100+
2
101+
5
94102
== MacJapanese ==
95103
2
96104
6

0 commit comments

Comments
 (0)