/* * wchar => UTF-8 */ int mbfl_filt_conv_wchar_utf8_mobile(int c, mbfl_convert_filter *filter) { if (c >= 0 && c < 0x110000) { int s1, c1; if ((filter->to->no_encoding == mbfl_no_encoding_utf8_docomo && mbfilter_unicode2sjis_emoji_docomo(c, &s1, filter) > 0 && mbfilter_conv_map_tbl(s1, &c1, mbfl_docomo2uni_pua, 4) > 0) || (filter->to->no_encoding == mbfl_no_encoding_utf8_kddi_a && mbfilter_unicode2sjis_emoji_kddi(c, &s1, filter) > 0 && mbfilter_conv_map_tbl(s1, &c1, mbfl_kddi2uni_pua, 7) > 0) || (filter->to->no_encoding == mbfl_no_encoding_utf8_kddi_b && mbfilter_unicode2sjis_emoji_kddi(c, &s1, filter) > 0 && mbfilter_conv_map_tbl(s1, &c1, mbfl_kddi2uni_pua_b, 8) > 0) || (filter->to->no_encoding == mbfl_no_encoding_utf8_sb && mbfilter_unicode2sjis_emoji_sb(c, &s1, filter) > 0 && mbfilter_conv_map_tbl(s1, &c1, mbfl_sb2uni_pua, 6) > 0)) { c = c1; } if (filter->status == 1 && filter->cache > 0) { return c; } if (c < 0x80) { CK((*filter->output_function)(c, filter->data)); } else if (c < 0x800) { CK((*filter->output_function)(((c >> 6) & 0x1f) | 0xc0, filter->data)); CK((*filter->output_function)((c & 0x3f) | 0x80, filter->data)); } else if (c < 0x10000) {
/* * wchar => ISO-2022-JP-Mobile */ int mbfl_filt_conv_wchar_2022jp_mobile(int c, mbfl_convert_filter *filter) { int c1, c2, s1, s2; s1 = 0; s2 = 0; if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) { s1 = ucs_a1_jis_table[c - ucs_a1_jis_table_min]; } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) { s1 = ucs_a2_jis_table[c - ucs_a2_jis_table_min]; } else if (c >= ucs_i_jis_table_min && c < ucs_i_jis_table_max) { s1 = ucs_i_jis_table[c - ucs_i_jis_table_min]; } else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) { s1 = ucs_r_jis_table[c - ucs_r_jis_table_min]; } else if (c >= 0xe000 && c < (0xe000 + 20*94)) { /* user (95ku - 114ku) */ s1 = c - 0xe000; c1 = s1/94 + 0x7f; c2 = s1%94 + 0x21; s1 = (c1 << 8) | c2; } if (s1 <= 0) { c1 = c & ~MBFL_WCSPLANE_MASK; if (c1 == MBFL_WCSPLANE_WINCP932) { s1 = c & MBFL_WCSPLANE_MASK; s2 = 1; } else if (c1 == MBFL_WCSPLANE_JIS0208) { s1 = c & MBFL_WCSPLANE_MASK; } else if (c1 == MBFL_WCSPLANE_JIS0212) { s1 = c & MBFL_WCSPLANE_MASK; s1 |= 0x8080; } else if (c == 0xa5) { /* YEN SIGN */ s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x2131; /* FULLWIDTH MACRON */ } else if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */ s1 = 0x2140; } else if (c == 0xff5e) { /* FULLWIDTH TILDE */ s1 = 0x2141; } else if (c == 0x2225) { /* PARALLEL TO */ s1 = 0x2142; } else if (c == 0xff0d) { /* FULLWIDTH HYPHEN-MINUS */ s1 = 0x215d; } else if (c == 0xffe0) { /* FULLWIDTH CENT SIGN */ s1 = 0x2171; } else if (c == 0xffe1) { /* FULLWIDTH POUND SIGN */ s1 = 0x2172; } else if (c == 0xffe2) { /* FULLWIDTH NOT SIGN */ s1 = 0x224c; } } if ((s1 <= 0) || (s1 >= 0xa1a1 && s2 == 0)) { /* not found or X 0212 */ s1 = -1; c1 = 0; c2 = cp932ext1_ucs_table_max - cp932ext1_ucs_table_min; while (c1 < c2) { /* CP932 vendor ext1 (13ku) */ if (c == cp932ext1_ucs_table[c1]) { s1 = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21); break; } c1++; } if (c == 0) { s1 = 0; } else if (s1 <= 0) { s1 = -1; } } if (filter->to->no_encoding == mbfl_no_encoding_2022jp_kddi && mbfilter_unicode2sjis_emoji_kddi(c, &s1, filter) > 0) { CODE2JIS(c1,c2,s1,s2); s1 -= 0x1600; } if (filter->status == 1 && filter->cache > 0) { return c; } if (s1 >= 0) { if (s1 < 0x80) { /* latin */ 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' */ } CK((*filter->output_function)(s1, filter->data)); filter->status = 0; } else if (s1 > 0xa0 && s1 < 0xe0) { /* 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)(s1 & 0x7f, filter->data)); } else if (s1 < 0x7e7f) { /* 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)((s1 >> 8) & 0xff, filter->data)); CK((*filter->output_function)(s1 & 0x7f, filter->data)); } } else { if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {