Skip to content

Commit 4aa7430

Browse files
committed
Add mbstring identify filter for '7bit' encoding
1 parent 0ffc1f5 commit 4aa7430

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

ext/mbstring/libmbfl/filters/mbfilter_7bit.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "mbfilter.h"
3232
#include "mbfilter_7bit.h"
3333

34+
static int mbfl_filt_ident_7bit(int c, mbfl_identify_filter *filter);
35+
3436
const mbfl_encoding mbfl_encoding_7bit = {
3537
mbfl_no_encoding_7bit,
3638
"7bit",
@@ -42,6 +44,12 @@ const mbfl_encoding mbfl_encoding_7bit = {
4244
NULL
4345
};
4446

47+
const struct mbfl_identify_vtbl vtbl_identify_7bit = {
48+
mbfl_no_encoding_7bit,
49+
mbfl_filt_ident_common_ctor,
50+
mbfl_filt_ident_7bit
51+
};
52+
4553
const struct mbfl_convert_vtbl vtbl_8bit_7bit = {
4654
mbfl_no_encoding_8bit,
4755
mbfl_no_encoding_7bit,
@@ -78,3 +86,11 @@ int mbfl_filt_conv_any_7bit(int c, mbfl_convert_filter *filter)
7886
}
7987
return c;
8088
}
89+
90+
static int mbfl_filt_ident_7bit(int c, mbfl_identify_filter *filter)
91+
{
92+
if (c >= 0x80) {
93+
filter->flag = 1;
94+
}
95+
return c;
96+
}

ext/mbstring/libmbfl/filters/mbfilter_7bit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "mbfilter.h"
3535

3636
extern const mbfl_encoding mbfl_encoding_7bit;
37+
extern const struct mbfl_identify_vtbl vtbl_identify_7bit;
3738
extern const struct mbfl_convert_vtbl vtbl_8bit_7bit;
3839
extern const struct mbfl_convert_vtbl vtbl_7bit_8bit;
3940

ext/mbstring/libmbfl/mbfl/mbfl_ident.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static const struct mbfl_identify_vtbl *mbfl_identify_filter_list[] = {
159159
&vtbl_identify_cp50221,
160160
&vtbl_identify_cp50222,
161161
&vtbl_identify_gb18030,
162+
&vtbl_identify_7bit,
162163
&vtbl_identify_false,
163164
NULL
164165
};

0 commit comments

Comments
 (0)