Moriyoshi Koizumi
moriy****@users*****
2006年 11月 28日 (火) 18:00:02 JST
moriyoshi 06/11/28 18:00:02 Modified: filters Tag: LIBMBFL_1_0 Makefile.am mbfilter_euc_jp_win.c mbfilter_jis.c mbfilter_jis.h unicode_table_jis.h mbfl Tag: LIBMBFL_1_0 mbfl_convert.c mbfl_encoding.c mbfl_encoding.h mbfl_ident.c Added: filters Tag: LIBMBFL_1_0 mbfilter_cp51932.c mbfilter_cp51932.h Log: - Merged CP51932 patch by Miracle Linux. - Please use this branch for production! Revision Changes Path No revision No revision 1.7.2.11 +2 -0 libmbfl/filters/Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/filters/Makefile.am,v retrieving revision 1.7.2.10 retrieving revision 1.7.2.11 diff -u -r1.7.2.10 -r1.7.2.11 --- Makefile.am 15 Nov 2006 08:55:07 -0000 1.7.2.10 +++ Makefile.am 28 Nov 2006 09:00:02 -0000 1.7.2.11 @@ -42,6 +42,7 @@ mbfilter_utf7imap.c \ mbfilter_euc_jp_win.c \ mbfilter_cp932.c \ + mbfilter_cp51932.c \ mbfilter_euc_cn.c \ mbfilter_euc_kr.c \ mbfilter_uhc.c \ @@ -102,6 +103,7 @@ mbfilter_utf8.h \ mbfilter_uuencode.h \ mbfilter_cp5022x.h \ + mbfilter_cp51932.h \ mbfilter_tl_jisx0201_jisx0208.h \ unicode_prop.h \ unicode_table_big5.h \ 1.3.2.2 +2 -1 libmbfl/filters/mbfilter_euc_jp_win.c Index: mbfilter_euc_jp_win.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/filters/mbfilter_euc_jp_win.c,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -r1.3.2.1 -r1.3.2.2 --- mbfilter_euc_jp_win.c 15 Nov 2006 08:55:07 -0000 1.3.2.1 +++ mbfilter_euc_jp_win.c 28 Nov 2006 09:00:02 -0000 1.3.2.2 @@ -60,7 +60,8 @@ }; -static const char *mbfl_encoding_eucjp_win_aliases[] = {"eucJP-open", NULL}; +static const char *mbfl_encoding_eucjp_win_aliases[] = {"eucJP-open", + "eucJP-ms", NULL}; const struct mbfl_identify_vtbl vtbl_identify_eucjpwin = { mbfl_no_encoding_eucjp_win, 1.3.2.3 +146 -8 libmbfl/filters/mbfilter_jis.c Index: mbfilter_jis.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/filters/mbfilter_jis.c,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.3 diff -u -r1.3.2.2 -r1.3.2.3 --- mbfilter_jis.c 15 Nov 2006 08:55:07 -0000 1.3.2.2 +++ mbfilter_jis.c 28 Nov 2006 09:00:02 -0000 1.3.2.3 @@ -58,6 +58,15 @@ MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE }; +const mbfl_encoding mbfl_encoding_2022jpms = { + mbfl_no_encoding_2022jpms, + "ISO-2022-JP-MS", + "ISO-2022-JP-MS", + NULL, + NULL, + MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE +}; + const struct mbfl_identify_vtbl vtbl_identify_jis = { mbfl_no_encoding_jis, mbfl_filt_ident_common_ctor, @@ -72,6 +81,13 @@ mbfl_filt_ident_2022jp }; +const struct mbfl_identify_vtbl vtbl_identify_2022jpms = { + mbfl_no_encoding_2022jpms, + mbfl_filt_ident_common_ctor, + mbfl_filt_ident_common_dtor, + mbfl_filt_ident_2022jp +}; + const struct mbfl_convert_vtbl vtbl_jis_wchar = { mbfl_no_encoding_jis, mbfl_no_encoding_wchar, @@ -108,6 +124,24 @@ mbfl_filt_conv_any_jis_flush }; +const struct mbfl_convert_vtbl vtbl_2022jpms_wchar = { + mbfl_no_encoding_2022jpms, + mbfl_no_encoding_wchar, + mbfl_filt_conv_common_ctor, + mbfl_filt_conv_common_dtor, + mbfl_filt_conv_jis_wchar, + mbfl_filt_conv_common_flush +}; + +const struct mbfl_convert_vtbl vtbl_wchar_2022jpms = { + mbfl_no_encoding_wchar, + mbfl_no_encoding_2022jpms, + mbfl_filt_conv_common_ctor, + mbfl_filt_conv_common_dtor, + mbfl_filt_conv_wchar_jis, + mbfl_filt_conv_any_jis_flush +}; + #define CK(statement) do { if ((statement) < 0) return (-1); } while (0) /* @@ -130,12 +164,10 @@ filter->status += 2; } else if (c == 0x0e) { /* "kana in" */ filter->status = 0x20; + CK((*filter->output_function)(c, filter->data)); } else if (c == 0x0f) { /* "kana out" */ filter->status = 0; - } else if (filter->status == 0x10 && c == 0x5c) { /* YEN SIGN */ - CK((*filter->output_function)(0xa5, filter->data)); - } else if (filter->status == 0x10 && c == 0x7e) { /* OVER LINE */ - CK((*filter->output_function)(0x203e, filter->data)); + CK((*filter->output_function)(c, filter->data)); } else if (filter->status == 0x20 && c > 0x20 && c < 0x60) { /* kana */ CK((*filter->output_function)(0xff40 + c, filter->data)); } else if ((filter->status == 0x80 || filter->status == 0x90) && c > 0x20 && c < 0x7f) { /* kanji first char */ @@ -161,9 +193,34 @@ s = (c1 - 0x21)*94 + c - 0x21; if (filter->status == 0x80) { if (s >= 0 && s < jisx0208_ucs_table_size) { + if ((filter->from)->no_encoding != + mbfl_no_encoding_2022jpms) { w = jisx0208_ucs_table[s]; + } + else { + if ((c1 - 0x21) == 12) { + w = cp932ext1_ucs_table[s-12*94]; + } + else { + if (c1 >= 0x79 && c1 <= 0x7c) { + w = cp932ext2_ucs_table[s-(0x79-0x21)*94]; + } + else { + w = jisx0208_ucs_table[s]; + } + } + } } else { + if ((filter->from)->no_encoding != + mbfl_no_encoding_2022jpms) { + w = 0; + } else { + if (c1 >= 0x79 && c1 <= 0x7c) { + w = cp932ext2_ucs_table[s-(0x79-0x21)*94]; + } else { w = 0; + } + } } if (w <= 0) { w = (c1 << 8) | c; @@ -287,7 +344,7 @@ int mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter) { - int c1, s; + int c1, c2, s; s = 0; if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) { @@ -299,6 +356,18 @@ } 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]; } + if (s > 0x8080 && s < 0x10000 && + ((filter->to)->no_encoding == mbfl_no_encoding_2022jpms)) { + c1 = 0; + c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min; + while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */ + if (c == cp932ext2_ucs_table[c1]) { + s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21); + break; + } + c1++; + } + } if (s <= 0) { c1 = c & ~MBFL_WCSPLANE_MASK; if (c1 == MBFL_WCSPLANE_JIS0208) { @@ -327,8 +396,30 @@ } if (c == 0) { s = 0; - } else if (s <= 0) { + } else if (s <= 0 && ((filter->to)->no_encoding == + mbfl_no_encoding_2022jpms)) { s = -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]) { + s = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21); + break; + } + c1++; + } + if (s < 0 && ((filter->to)->no_encoding == + mbfl_no_encoding_2022jpms)) { + c1 = 0; + c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min; + while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */ + if (c == cp932ext2_ucs_table[c1]) { + s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21); + break; + } + c1++; + } + } } } if (s >= 0) { @@ -392,7 +483,7 @@ int mbfl_filt_conv_wchar_2022jp(int c, mbfl_convert_filter *filter) { - int s; + int c1, c2, s; s = 0; if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) { @@ -428,9 +519,47 @@ s = 0; } else if (s <= 0) { s = -1; + if ( (filter->to)->no_encoding == + mbfl_no_encoding_2022jpms) { + c1 = 0; + c2 = cp932ext1_ucs_table_max - cp932ext1_ucs_table_min; + while (c1 < c2) { /* CP932 vendor ext1 (13ku) */ + if (c == cp932ext1_ucs_table[c1]) { + s = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21); + break; + } + c1++; + } + if ((filter->to)->no_encoding == + mbfl_no_encoding_2022jpms) { + c1 = 0; + c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min; + while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */ + if (c == cp932ext2_ucs_table[c1]) { + s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21); + break; + } + c1++; + } + } + } } - } else if ((s >= 0x80 && s < 0x2121) || (s > 0x8080)) { + } else if (((s >= 0x80 && s < 0x2121) && + (filter->to)->no_encoding != mbfl_no_encoding_2022jpms) || + (s > 0x8080)) { s = -1; + if ((filter->to)->no_encoding == + mbfl_no_encoding_2022jpms) { + c1 = 0; + c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min; + while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */ + if (c == cp932ext2_ucs_table[c1]) { + s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21); + break; + } + c1++; + } + } } if (s >= 0) { if (s < 0x80) { /* ASCII */ @@ -441,6 +570,15 @@ } filter->status = 0; CK((*filter->output_function)(s, filter->data)); + } else if (s < 0x100 && ((filter->to)->no_encoding == + mbfl_no_encoding_2022jpms)) { /* 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 < 0x10000) { /* X 0208 */ if ((filter->status & 0xff00) != 0x200) { CK((*filter->output_function)(0x1b, filter->data)); /* ESC */ 1.3.2.1 +4 -0 libmbfl/filters/mbfilter_jis.h Index: mbfilter_jis.h =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/filters/mbfilter_jis.h,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- mbfilter_jis.h 20 Dec 2002 18:17:31 -0000 1.3 +++ mbfilter_jis.h 28 Nov 2006 09:00:02 -0000 1.3.2.1 @@ -34,12 +34,16 @@ extern const mbfl_encoding mbfl_encoding_jis; extern const mbfl_encoding mbfl_encoding_2022jp; +extern const mbfl_encoding mbfl_encoding_2022jpms; extern const struct mbfl_identify_vtbl vtbl_identify_2022jp; +extern const struct mbfl_identify_vtbl vtbl_identify_2022jpms; extern const struct mbfl_identify_vtbl vtbl_identify_jis; extern const struct mbfl_convert_vtbl vtbl_jis_wchar; extern const struct mbfl_convert_vtbl vtbl_wchar_jis; extern const struct mbfl_convert_vtbl vtbl_2022jp_wchar; extern const struct mbfl_convert_vtbl vtbl_wchar_2022jp; +extern const struct mbfl_convert_vtbl vtbl_2022jpms_wchar; +extern const struct mbfl_convert_vtbl vtbl_wchar_2022jpms; int mbfl_filt_conv_jis_wchar(int c, mbfl_convert_filter *filter); int mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter); 1.1.1.1.2.1 +7 -7 libmbfl/filters/unicode_table_jis.h Index: unicode_table_jis.h =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/filters/unicode_table_jis.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- unicode_table_jis.h 7 Dec 2002 19:20:45 -0000 1.1.1.1 +++ unicode_table_jis.h 28 Nov 2006 09:00:02 -0000 1.1.1.1.2.1 @@ -36,13 +36,13 @@ 0xFF1F,0xFF01,0x309B,0x309C,0x00B4,0xFF40,0x00A8,0xFF3E, 0xFFE3,0xFF3F,0x30FD,0x30FE,0x309D,0x309E,0x3003,0x4EDD, 0x3005,0x3006,0x3007,0x30FC,0x2015,0x2010,0xFF0F,0xFF3C, - 0x301C,0x2016,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C, + 0xFF5E,0x2225,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C, 0x201D,0xFF08,0xFF09,0x3014,0x3015,0xFF3B,0xFF3D,0xFF5B, 0xFF5D,0x3008,0x3009,0x300A,0x300B,0x300C,0x300D,0x300E, - 0x300F,0x3010,0x3011,0xFF0B,0x2212,0x00B1,0x00D7,0x00F7, + 0x300F,0x3010,0x3011,0xFF0B,0xFF0D,0x00B1,0x00D7,0x00F7, 0xFF1D,0x2260,0xFF1C,0xFF1E,0x2266,0x2267,0x221E,0x2234, 0x2642,0x2640,0x00B0,0x2032,0x2033,0x2103,0xFFE5,0xFF04, - 0x00A2,0x00A3,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7, + 0xFFE0,0xFFE1,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7, 0x2606,0x2605,0x25CB,0x25CF,0x25CE,0x25C7, /* ku 2 */ @@ -51,7 +51,7 @@ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x2208,0x220B,0x2286,0x2287,0x2282,0x2283,0x222A, 0x2229,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, - 0x0000,0x2227,0x2228,0x00AC,0x21D2,0x21D4,0x2200,0x2203, + 0x0000,0x2227,0x2228,0xFFE2,0x21D2,0x21D4,0x2200,0x2203, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x2220,0x22A5,0x2312,0x2202,0x2207, 0x2261,0x2252,0x226A,0x226B,0x221A,0x223D,0x221D,0x2235, @@ -1217,9 +1217,9 @@ /* ku 2 */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x02D8,0x02C7, - 0x00B8,0x02D9,0x02DD,0x00AF,0x02DB,0x02DA,0x007E,0x0384, + 0x00B8,0x02D9,0x02DD,0x00AF,0x02DB,0x02DA,0xFF5E,0x0384, 0x0385,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, - 0x0000,0x00A1,0x00A6,0x00BF,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x00A1,0xFFE4,0x00BF,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, @@ -2471,7 +2471,7 @@ /* 2100h */ 0x0000,0x0000,0x0000,0x216E,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, - 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xA2F1,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2d62,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0xA2EF,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x2272,0x0000,0x0000,0x0000,0x0000, No revision No revision 1.1.2.1 +0 -0 libmbfl/filters/mbfilter_cp51932.c 1.1.2.1 +0 -0 libmbfl/filters/mbfilter_cp51932.h No revision No revision 1.1.2.8 +5 -0 libmbfl/mbfl/mbfl_convert.c Index: mbfl_convert.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_convert.c,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- mbfl_convert.c 15 Nov 2006 08:55:07 -0000 1.1.2.7 +++ mbfl_convert.c 28 Nov 2006 09:00:02 -0000 1.1.2.8 @@ -51,6 +51,7 @@ #include "filters/mbfilter_euc_kr.h" #include "filters/mbfilter_iso2022_kr.h" #include "filters/mbfilter_sjis.h" +#include "filters/mbfilter_cp51932.h" #include "filters/mbfilter_jis.h" #include "filters/mbfilter_euc_jp.h" #include "filters/mbfilter_euc_jp_win.h" @@ -103,12 +104,16 @@ &vtbl_wchar_eucjp, &vtbl_sjis_wchar, &vtbl_wchar_sjis, + &vtbl_cp51932_wchar, + &vtbl_wchar_cp51932, &vtbl_jis_wchar, &vtbl_wchar_jis, &vtbl_jis_ms_wchar, &vtbl_wchar_jis_ms, &vtbl_2022jp_wchar, &vtbl_wchar_2022jp, + &vtbl_2022jpms_wchar, + &vtbl_wchar_2022jpms, &vtbl_eucjpwin_wchar, &vtbl_wchar_eucjpwin, &vtbl_sjiswin_wchar, 1.1.2.12 +3 -0 libmbfl/mbfl/mbfl_encoding.c Index: mbfl_encoding.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_encoding.c,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -r1.1.2.11 -r1.1.2.12 --- mbfl_encoding.c 15 Nov 2006 08:55:07 -0000 1.1.2.11 +++ mbfl_encoding.c 28 Nov 2006 09:00:02 -0000 1.1.2.12 @@ -57,6 +57,7 @@ #include "filters/mbfilter_euc_kr.h" #include "filters/mbfilter_iso2022_kr.h" #include "filters/mbfilter_sjis.h" +#include "filters/mbfilter_cp51932.h" #include "filters/mbfilter_jis.h" #include "filters/mbfilter_euc_jp.h" #include "filters/mbfilter_euc_jp_win.h" @@ -150,8 +151,10 @@ &mbfl_encoding_sjis, &mbfl_encoding_eucjp_win, &mbfl_encoding_sjis_win, + &mbfl_encoding_cp51932, &mbfl_encoding_jis, &mbfl_encoding_2022jp, + &mbfl_encoding_2022jpms, &mbfl_encoding_cp1252, &mbfl_encoding_8859_1, &mbfl_encoding_8859_2, 1.1.2.8 +2 -0 libmbfl/mbfl/mbfl_encoding.h Index: mbfl_encoding.h =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_encoding.h,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- mbfl_encoding.h 15 Nov 2006 08:55:07 -0000 1.1.2.7 +++ mbfl_encoding.h 28 Nov 2006 09:00:02 -0000 1.1.2.8 @@ -70,8 +70,10 @@ mbfl_no_encoding_eucjp_win, mbfl_no_encoding_sjis_win, mbfl_no_encoding_sjis_mac, + mbfl_no_encoding_cp51932, mbfl_no_encoding_jis, mbfl_no_encoding_2022jp, + mbfl_no_encoding_2022jpms, mbfl_no_encoding_cp1252, mbfl_no_encoding_8859_1, mbfl_no_encoding_8859_2, 1.1.2.6 +1 -0 libmbfl/mbfl/mbfl_ident.c Index: mbfl_ident.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_ident.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- mbfl_ident.c 15 Nov 2006 08:55:07 -0000 1.1.2.5 +++ mbfl_ident.c 28 Nov 2006 09:00:02 -0000 1.1.2.6 @@ -108,6 +108,7 @@ &vtbl_identify_jis, &vtbl_identify_jis_ms, &vtbl_identify_2022jp, + &vtbl_identify_2022jpms, &vtbl_identify_euccn, &vtbl_identify_cp936, &vtbl_identify_hz,