Skip to content

Commit fcbe45d

Browse files
committed
Remove useless mbstring encoding 'CP50220-raw'
CP50220 is a variant of ISO-2022-JP invented by MicroSoft, which handles some Unicode characters which are not representable in ISO-2022-JP by converting them to similar characters which are representable. What, then, is CP50220-raw? An Internet search turns up absolutely nothing. Reference works which I consulted don't say anything about it. Other text conversion libraries don't support it. From looking at the code: It's just the same as CP50220, but it accepts unmapped JIS X 0208 characters passed through from other Japanese encodings and silently encodes them using the usual ISO-2022-JP escape sequence and representation for JIS X 0208 characters. It's hard to see how this could be useful. OK, let me come out and say it: it's _not_ useful. We can confidently jettison this (mis)feature.
1 parent 888f5d7 commit fcbe45d

File tree

4 files changed

+8
-61
lines changed

4 files changed

+8
-61
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ static void mbfl_filt_conv_wchar_cp50220_dtor(mbfl_convert_filter *filt);
4141
static void mbfl_filt_conv_wchar_cp50220_copy(mbfl_convert_filter *src, mbfl_convert_filter *dest);
4242
static int mbfl_filt_conv_cp5022x_wchar_flush(mbfl_convert_filter *filter);
4343

44+
/* Previously, a dubious 'encoding' called 'cp50220raw' was supported
45+
* This was just CP50220, but the implementation was less strict regarding
46+
* invalid characters; it would silently pass some through
47+
* This 'encoding' only existed in mbstring. In case some poor, lost soul is
48+
* still using it, retain minimal support by aliasing it to CP50220 */
49+
static const char *cp50220_aliases[] = {"cp50220raw", "cp50220-raw", NULL};
50+
4451
const mbfl_encoding mbfl_encoding_jis_ms = {
4552
mbfl_no_encoding_jis_ms,
4653
"JIS-ms",
@@ -56,24 +63,13 @@ const mbfl_encoding mbfl_encoding_cp50220 = {
5663
mbfl_no_encoding_cp50220,
5764
"CP50220",
5865
"ISO-2022-JP",
59-
NULL,
66+
cp50220_aliases,
6067
NULL,
6168
MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_GL_UNSAFE,
6269
&vtbl_cp50220_wchar,
6370
&vtbl_wchar_cp50220
6471
};
6572

66-
const mbfl_encoding mbfl_encoding_cp50220raw = {
67-
mbfl_no_encoding_cp50220raw,
68-
"CP50220raw",
69-
"ISO-2022-JP",
70-
NULL,
71-
NULL,
72-
MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_GL_UNSAFE,
73-
&vtbl_cp50220raw_wchar,
74-
&vtbl_wchar_cp50220raw
75-
};
76-
7773
const mbfl_encoding mbfl_encoding_cp50221 = {
7874
mbfl_no_encoding_cp50221,
7975
"CP50221",
@@ -136,26 +132,6 @@ const struct mbfl_convert_vtbl vtbl_wchar_cp50220 = {
136132
mbfl_filt_conv_wchar_cp50220_copy
137133
};
138134

139-
const struct mbfl_convert_vtbl vtbl_cp50220raw_wchar = {
140-
mbfl_no_encoding_cp50220raw,
141-
mbfl_no_encoding_wchar,
142-
mbfl_filt_conv_common_ctor,
143-
NULL,
144-
mbfl_filt_conv_jis_ms_wchar,
145-
mbfl_filt_conv_common_flush,
146-
NULL,
147-
};
148-
149-
const struct mbfl_convert_vtbl vtbl_wchar_cp50220raw = {
150-
mbfl_no_encoding_wchar,
151-
mbfl_no_encoding_cp50220raw,
152-
mbfl_filt_conv_wchar_cp50220_ctor,
153-
mbfl_filt_conv_wchar_cp50220_dtor,
154-
mbfl_filt_conv_wchar_cp50220raw,
155-
mbfl_filt_conv_any_jis_flush,
156-
mbfl_filt_conv_wchar_cp50220_copy
157-
};
158-
159135
const struct mbfl_convert_vtbl vtbl_cp50221_wchar = {
160136
mbfl_no_encoding_cp50221,
161137
mbfl_no_encoding_wchar,
@@ -571,29 +547,6 @@ mbfl_filt_conv_wchar_cp50220_dtor(mbfl_convert_filter *filt)
571547
}
572548
}
573549

574-
/*
575-
* wchar => cp50220raw
576-
*/
577-
int
578-
mbfl_filt_conv_wchar_cp50220raw(int c, mbfl_convert_filter *filter)
579-
{
580-
if (c & MBFL_WCSPLANE_JIS0208) {
581-
const int s = c & MBFL_WCSPLANE_MASK;
582-
583-
if ((filter->status & 0xff00) != 0x200) {
584-
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
585-
CK((*filter->output_function)(0x24, filter->data)); /* '$' */
586-
CK((*filter->output_function)(0x42, filter->data)); /* 'B' */
587-
filter->status = 0x200;
588-
}
589-
CK((*filter->output_function)((s >> 8) & 0x7f, filter->data));
590-
CK((*filter->output_function)(s & 0x7f, filter->data));
591-
return c;
592-
} else {
593-
return mbfl_filt_conv_wchar_cp50221(c, filter);
594-
}
595-
}
596-
597550
/*
598551
* wchar => CP50221
599552
*/

ext/mbstring/libmbfl/filters/mbfilter_cp5022x.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@
3434

3535
extern const mbfl_encoding mbfl_encoding_jis_ms;
3636
extern const mbfl_encoding mbfl_encoding_cp50220;
37-
extern const mbfl_encoding mbfl_encoding_cp50220raw;
3837
extern const mbfl_encoding mbfl_encoding_cp50221;
3938
extern const mbfl_encoding mbfl_encoding_cp50222;
4039

4140
extern const struct mbfl_convert_vtbl vtbl_jis_ms_wchar;
4241
extern const struct mbfl_convert_vtbl vtbl_wchar_jis_ms;
4342
extern const struct mbfl_convert_vtbl vtbl_cp50220_wchar;
4443
extern const struct mbfl_convert_vtbl vtbl_wchar_cp50220;
45-
extern const struct mbfl_convert_vtbl vtbl_cp50220raw_wchar;
46-
extern const struct mbfl_convert_vtbl vtbl_wchar_cp50220raw;
4744
extern const struct mbfl_convert_vtbl vtbl_cp50221_wchar;
4845
extern const struct mbfl_convert_vtbl vtbl_wchar_cp50221;
4946
extern const struct mbfl_convert_vtbl vtbl_cp50222_wchar;
@@ -52,7 +49,6 @@ extern const struct mbfl_convert_vtbl vtbl_wchar_cp50222;
5249
int mbfl_filt_conv_jis_ms_wchar(int c, mbfl_convert_filter *filter);
5350
int mbfl_filt_conv_wchar_jis_ms(int c, mbfl_convert_filter *filter);
5451
int mbfl_filt_conv_wchar_cp50220(int c, mbfl_convert_filter *filter);
55-
int mbfl_filt_conv_wchar_cp50220raw(int c, mbfl_convert_filter *filter);
5652
int mbfl_filt_conv_wchar_cp50221(int c, mbfl_convert_filter *filter);
5753
int mbfl_filt_conv_wchar_cp50222(int c, mbfl_convert_filter *filter);
5854
int mbfl_filt_conv_wchar_cp50222_flush(mbfl_convert_filter *filter);

ext/mbstring/libmbfl/mbfl/mbfl_encoding.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ static const mbfl_encoding *mbfl_encoding_ptr_list[] = {
165165
&mbfl_encoding_2022jp_2004,
166166
&mbfl_encoding_2022jp_kddi,
167167
&mbfl_encoding_cp50220,
168-
&mbfl_encoding_cp50220raw,
169168
&mbfl_encoding_cp50221,
170169
&mbfl_encoding_cp50222,
171170
NULL

ext/mbstring/libmbfl/mbfl/mbfl_encoding.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ enum mbfl_no_encoding {
115115
mbfl_no_encoding_cp850,
116116
mbfl_no_encoding_jis_ms,
117117
mbfl_no_encoding_cp50220,
118-
mbfl_no_encoding_cp50220raw,
119118
mbfl_no_encoding_cp50221,
120119
mbfl_no_encoding_cp50222,
121120
mbfl_no_encoding_charset_max

0 commit comments

Comments
 (0)