* This was just CP50220, but the implementation was less strict regarding
* invalid characters; it would silently pass some through
* This 'encoding' only existed in mbstring. In case some poor, lost soul is
- * still using it, retain minimal support by aliasing it to CP50220 */
-static const char *cp50220_aliases[] = {"cp50220raw", "cp50220-raw", NULL};
-
-const mbfl_encoding mbfl_encoding_jis_ms = {
- mbfl_no_encoding_jis_ms,
- "JIS-ms",
- "ISO-2022-JP",
- NULL,
- NULL,
- MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_GL_UNSAFE,
- &vtbl_jis_ms_wchar,
- &vtbl_wchar_jis_ms
-};
+ * still using it, retain minimal support by aliasing it to CP50220
+ *
+ * Further, mbstring also had a made-up encoding called "JIS-ms"
+ * This was the same as CP5022{0,1,2}, but without their special ways of
+ * handling conversion of Unicode half-width katakana */
+static const char *cp50220_aliases[] = {"cp50220raw", "cp50220-raw", "JIS-ms", NULL};
const mbfl_encoding mbfl_encoding_cp50220 = {
mbfl_no_encoding_cp50220,
&vtbl_wchar_cp50222
};
-const struct mbfl_convert_vtbl vtbl_jis_ms_wchar = {
- mbfl_no_encoding_jis_ms,
- mbfl_no_encoding_wchar,
- mbfl_filt_conv_common_ctor,
- NULL,
- mbfl_filt_conv_jis_ms_wchar,
- mbfl_filt_conv_common_flush,
- NULL,
-};
-
-const struct mbfl_convert_vtbl vtbl_wchar_jis_ms = {
- mbfl_no_encoding_wchar,
- mbfl_no_encoding_jis_ms,
- mbfl_filt_conv_common_ctor,
- NULL,
- mbfl_filt_conv_wchar_jis_ms,
- mbfl_filt_conv_any_jis_flush,
- NULL,
-};
-
const struct mbfl_convert_vtbl vtbl_cp50220_wchar = {
mbfl_no_encoding_cp50220,
mbfl_no_encoding_wchar,
mbfl_filt_conv_common_ctor,
NULL,
- mbfl_filt_conv_jis_ms_wchar,
+ mbfl_filt_conv_cp5022x_wchar,
mbfl_filt_conv_cp5022x_wchar_flush,
NULL,
};
mbfl_no_encoding_wchar,
mbfl_filt_conv_common_ctor,
NULL,
- mbfl_filt_conv_jis_ms_wchar,
+ mbfl_filt_conv_cp5022x_wchar,
mbfl_filt_conv_cp5022x_wchar_flush,
NULL,
};
mbfl_no_encoding_wchar,
mbfl_filt_conv_common_ctor,
NULL,
- mbfl_filt_conv_jis_ms_wchar,
+ mbfl_filt_conv_cp5022x_wchar,
mbfl_filt_conv_cp5022x_wchar_flush,
NULL,
};
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
-/*
- * JIS-ms => wchar
- */
-int
-mbfl_filt_conv_jis_ms_wchar(int c, mbfl_convert_filter *filter)
+int mbfl_filt_conv_cp5022x_wchar(int c, mbfl_convert_filter *filter)
{
int c1, s, w;
return 0;
}
-/*
- * wchar => JIS
- */
-int
-mbfl_filt_conv_wchar_jis_ms(int c, mbfl_convert_filter *filter)
-{
- int s = 0;
-
- if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
- s = ucs_a1_jis_table[c - ucs_a1_jis_table_min];
- } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) {
- s = ucs_a2_jis_table[c - ucs_a2_jis_table_min];
- } else if (c >= ucs_i_jis_table_min && c < ucs_i_jis_table_max) {
- s = ucs_i_jis_table[c - ucs_i_jis_table_min];
- } else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) {
- s = ucs_r_jis_table[c - ucs_r_jis_table_min];
- } else if (c >= 0xe000 && c < (0xe000 + 10 * 94)) {
- /* PUE => Microsoft extended (pseudo 95ku - 114ku) */
- /* See http://www.opengroup.or.jp/jvc/cde/ucs-conv.html#ch4_2 */
- s = c - 0xe000;
- s = ((s / 94) + 0x7F) << 8 | ((s % 94) + 0x21);
- } else if (c >= (0xe000 + 10 * 94) && c <= (0xe000 + 20 * 94)) {
- /* PUE => JISX0212 user-defined (G3 85ku - 94ku) */
- /* See http://www.opengroup.or.jp/jvc/cde/ucs-conv.html#ch4_2 */
- s = c - (0xe000 + 10 * 94);
- s = (s / 94 + 0xf5) << 8 | (s % 94 + 0xa1);
- }
-
- /* do some transliteration */
- if (s <= 0) {
- if (c == 0xa5) { /* YEN SIGN */
- s = 0x1005c;
- } else if (c == 0x203e) { /* OVER LINE */
- s = 0x1007e;
- } else if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */
- s = 0x2140;
- } else if (c == 0x2225) { /* PARALLEL TO */
- s = 0x2142;
- } else if (c == 0xff0d) { /* FULLWIDTH HYPHEN-MINUS */
- s = 0x215d;
- } else if (c == 0xffe0) { /* FULLWIDTH CENT SIGN */
- s = 0x2171;
- } else if (c == 0xffe1) { /* FULLWIDTH POUND SIGN */
- s = 0x2172;
- } else if (c == 0xffe2) { /* FULLWIDTH NOT SIGN */
- s = 0x224c;
- }
- }
- if (s <= 0 || (s >= 0x8080 && s < 0x10000)) {
- int i;
- s = -1;
-
- for (i = 0;
- i < cp932ext1_ucs_table_max - cp932ext1_ucs_table_min; i++) {
- const int oh = cp932ext1_ucs_table_min / 94;
-
- if (c == cp932ext1_ucs_table[i]) {
- s = ((i / 94 + oh + 0x21) << 8) + (i % 94 + 0x21);
- break;
- }
- }
-
- if (s < 0) {
- const int oh = cp932ext2_ucs_table_min / 94;
- const int cp932ext2_ucs_table_size =
- cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
- for (i = 0; i < cp932ext2_ucs_table_size; i++) {
- if (c == cp932ext2_ucs_table[i]) {
- s = ((i / 94 + oh + 0x21) << 8) + (i % 94 + 0x21);
- break;
- }
- }
- }
-
- if (s < 0) {
- const int cp932ext3_ucs_table_size =
- cp932ext3_ucs_table_max - cp932ext3_ucs_table_min;
- const int limit = cp932ext3_ucs_table_size >
- cp932ext3_eucjp_table_size ?
- cp932ext3_eucjp_table_size:
- cp932ext3_ucs_table_size;
- for (i = 0; i < limit; i++) {
- if (c == cp932ext3_ucs_table[i]) {
- s = cp932ext3_eucjp_table[i];
- break;
- }
- }
- }
-
- if (c == 0) {
- s = 0;
- } else if (s <= 0) {
- s = -1;
- }
- }
-
- if (s >= 0) {
- if (s < 0x80) { /* ASCII */
- if ((filter->status & 0xff00) != 0) {
- CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
- CK((*filter->output_function)(0x28, filter->data)); /* '(' */
- CK((*filter->output_function)(0x42, filter->data)); /* 'B' */
- }
- filter->status = 0;
- CK((*filter->output_function)(s, filter->data));
- } else if (s < 0x100) { /* kana */
- if ((filter->status & 0xff00) != 0x100) {
- CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
- CK((*filter->output_function)(0x28, filter->data)); /* '(' */
- CK((*filter->output_function)(0x49, filter->data)); /* 'I' */
- }
- filter->status = 0x100;
- CK((*filter->output_function)(s & 0x7f, filter->data));
- } else if (s < 0x8080) { /* X 0208 */
- if ((filter->status & 0xff00) != 0x200) {
- CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
- CK((*filter->output_function)(0x24, filter->data)); /* '$' */
- CK((*filter->output_function)(0x42, filter->data)); /* 'B' */
- }
- filter->status = 0x200;
- CK((*filter->output_function)((s >> 8) & 0xff, filter->data));
- CK((*filter->output_function)(s & 0xff, filter->data));
- } else if (s < 0x10000) { /* X 0212 */
- if ((filter->status & 0xff00) != 0x300) {
- CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
- CK((*filter->output_function)(0x24, filter->data)); /* '$' */
- CK((*filter->output_function)(0x28, filter->data)); /* '(' */
- CK((*filter->output_function)(0x44, filter->data)); /* 'D' */
- }
- filter->status = 0x300;
- CK((*filter->output_function)((s >> 8) & 0x7f, filter->data));
- CK((*filter->output_function)(s & 0x7f, filter->data));
- } else { /* X 0201 latin */
- if ((filter->status & 0xff00) != 0x400) {
- CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
- CK((*filter->output_function)(0x28, filter->data)); /* '(' */
- CK((*filter->output_function)(0x4a, filter->data)); /* 'J' */
- }
- filter->status = 0x400;
- CK((*filter->output_function)(s & 0x7f, filter->data));
- }
- } else {
- CK(mbfl_filt_conv_illegal_output(c, filter));
- }
-
- return c;
-}
-
/*
* wchar => CP50220
*/
}
filter->status &= 0xff;
- if (filter->flush_function != NULL) {
- return (*filter->flush_function)(filter->data);
+ if (filter->flush_function) {
+ (*filter->flush_function)(filter->data);
}
return 0;