]> granicus.if.org Git - php/commitdiff
MFH: added gb18030 encoding to mbstring/libmbfl.~
authorRui Hirokawa <hirokawa@php.net>
Sun, 14 Aug 2011 14:11:29 +0000 (14:11 +0000)
committerRui Hirokawa <hirokawa@php.net>
Sun, 14 Aug 2011 14:11:29 +0000 (14:11 +0000)
13 files changed:
ext/mbstring/config.m4
ext/mbstring/config.w32
ext/mbstring/libmbfl/filters/Makefile.am
ext/mbstring/libmbfl/filters/mbfilter_gb18030.c [new file with mode: 0644]
ext/mbstring/libmbfl/filters/mbfilter_gb18030.h [new file with mode: 0644]
ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c
ext/mbstring/libmbfl/filters/unicode_table_cp936.h
ext/mbstring/libmbfl/filters/unicode_table_gb18030.h [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfl_consts.h
ext/mbstring/libmbfl/mbfl/mbfl_convert.c
ext/mbstring/libmbfl/mbfl/mbfl_encoding.c
ext/mbstring/libmbfl/mbfl/mbfl_encoding.h
ext/mbstring/libmbfl/mbfl/mbfl_ident.c

index 6751605e1cbe40655eff4fab5162ed13f2f7b326..7af344f14123d0e60ca45830d14e5fd7fe34781a 100644 (file)
@@ -235,6 +235,7 @@ AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
      libmbfl/filters/mbfilter_cp866.c
      libmbfl/filters/mbfilter_cp932.c
      libmbfl/filters/mbfilter_cp936.c
+     libmbfl/filters/mbfilter_gb18030.c
      libmbfl/filters/mbfilter_euc_cn.c
      libmbfl/filters/mbfilter_euc_jp.c
      libmbfl/filters/mbfilter_euc_jp_win.c
index d069c3146da17e2acad548943e0660627267ec1d..8c8bea7e253813935a1c27efca577b6dbf44ad25 100644 (file)
@@ -29,7 +29,7 @@ if (PHP_MBSTRING != "no") {
                mbfilter_iso8859_2.c mbfilter_iso8859_3.c mbfilter_iso8859_4.c \
                mbfilter_iso8859_5.c mbfilter_iso8859_6.c mbfilter_iso8859_7.c \
                mbfilter_iso8859_8.c mbfilter_iso8859_9.c mbfilter_jis.c \
-               mbfilter_iso2022_jp_ms.c \
+               mbfilter_iso2022_jp_ms.c mbfilter_gb18030.c \
                mbfilter_koi8r.c mbfilter_qprint.c mbfilter_sjis.c mbfilter_ucs2.c \
                mbfilter_ucs4.c mbfilter_uhc.c mbfilter_utf16.c mbfilter_utf32.c \
                mbfilter_utf7.c mbfilter_utf7imap.c mbfilter_utf8.c mbfilter_utf8_mobile.c \
index 6edf690c84420dd0d6c8ae4e9680b74f8583c9cd..c1e414f011e53975848c6a26d4db9b919078c867 100644 (file)
@@ -53,6 +53,7 @@ libmbfl_filters_la_SOURCES=mbfilter_cp936.c \
        mbfilter_euc_kr.c \
        mbfilter_uhc.c \
        mbfilter_iso2022_jp_ms.c \
+       mbfilter_gb18030.c \
        mbfilter_iso2022_kr.c \
        mbfilter_cp866.c \
        mbfilter_koi8r.c \
@@ -76,6 +77,7 @@ libmbfl_filters_la_SOURCES=mbfilter_cp936.c \
        mbfilter_cp866.h \
        mbfilter_cp932.h \
        mbfilter_cp936.h \
+       mbfilter_gb18030.h \
        mbfilter_euc_cn.h \
        mbfilter_euc_jp.h \
        mbfilter_euc_jp_win.h \
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_gb18030.c b/ext/mbstring/libmbfl/filters/mbfilter_gb18030.c
new file mode 100644 (file)
index 0000000..31ed9f3
--- /dev/null
@@ -0,0 +1,444 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * the source code included in this files was separated from mbfilter_cp936.c
+ * by rui hirokawa <hirokawa@php.net> on 11 Aug 2011.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "mbfilter.h"
+#include "mbfilter_gb18030.h"
+
+#include "unicode_table_cp936.h"
+#include "unicode_table_gb18030.h"
+
+static int mbfl_filt_ident_gb18030(int c, mbfl_identify_filter *filter);
+
+static const char *mbfl_encoding_gb18030_aliases[] = {"gb-18030", "gb-18030-2000", NULL};
+
+const mbfl_encoding mbfl_encoding_gb18030 = {
+       mbfl_no_encoding_gb18030,
+       "GB18030",
+       "GB18030",
+       (const char *(*)[])&mbfl_encoding_gb18030_aliases,
+       NULL,
+       MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_GL_UNSAFE
+};
+
+const struct mbfl_identify_vtbl vtbl_identify_gb18030 = {
+       mbfl_no_encoding_gb18030,
+       mbfl_filt_ident_common_ctor,
+       mbfl_filt_ident_common_dtor,
+       mbfl_filt_ident_gb18030
+};
+
+const struct mbfl_convert_vtbl vtbl_gb18030_wchar = {
+       mbfl_no_encoding_gb18030,
+       mbfl_no_encoding_wchar,
+       mbfl_filt_conv_common_ctor,
+       mbfl_filt_conv_common_dtor,
+       mbfl_filt_conv_gb18030_wchar,
+       mbfl_filt_conv_common_flush
+};
+
+const struct mbfl_convert_vtbl vtbl_wchar_gb18030 = {
+       mbfl_no_encoding_wchar,
+       mbfl_no_encoding_gb18030,
+       mbfl_filt_conv_common_ctor,
+       mbfl_filt_conv_common_dtor,
+       mbfl_filt_conv_wchar_gb18030,
+       mbfl_filt_conv_common_flush
+};
+
+#define CK(statement)  do { if ((statement) < 0) return (-1); } while (0)
+
+
+int
+mbfl_bisec_srch(int w, const unsigned short *tbl, int n)
+{
+       int k, k1 = 0, k2 = n-1;
+       int match = 0;
+       
+       while (k1 < k2) {
+               k = (k1+k2) >> 1;
+               if (w <= tbl[2*k+1]) {
+                       k2 = k;
+               } else if (w >= tbl[2*k+2]) {
+                       k1 = k + 1;
+               } else {
+                       return -1;
+               }
+       }
+       return k1;
+}
+
+int
+mbfl_bisec_srch2(int w, const unsigned short tbl[], int n)
+{
+       int k, k1 = 0, k2 = n;
+       
+       if (w == tbl[0]) {
+               return 0;
+       }
+
+       while (k2 - k1 > 1) {
+               k = (k1 + k2) >> 1;
+               if (w < tbl[k]) {
+                       k2 = k;
+               } else if (w > tbl[k]) {
+                       k1 = k;
+               } else {
+                       return k;
+               }
+       }
+       return -1;
+}
+
+/*
+ * GB18030 => wchar
+ */
+int
+mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter)
+{
+       int k;
+       int c1, c2, c3, w = -1;
+
+       switch (filter->status) {
+       case 0:
+               if (c >= 0 && c < 0x80) {       /* latin */
+                       CK((*filter->output_function)(c, filter->data));
+               } else if (c == 0x80) { /* euro sign */
+                       CK((*filter->output_function)(0x20ac, filter->data));
+               } else if (c == 0xff) {
+                       CK((*filter->output_function)(0x00ff, filter->data));
+               } else if (c > 0x80 && c < 0xff) {      /* dbcs/fbcs lead byte */
+                       filter->status = 1;
+                       filter->cache = c;
+               } else {
+                       w = c & MBFL_WCSGROUP_MASK;
+                       w |= MBFL_WCSGROUP_THROUGH;
+                       CK((*filter->output_function)(w, filter->data));
+               }
+               break;
+
+       case 1:         /* dbcs/fbcs second byte */
+               c1 = filter->cache;
+               filter->status = 0;
+
+               if (c1 >= 0x81 && c1 <= 0x84 && c >= 0x30 && c <= 0x39) { /* 4 byte range: Unicode BMP */
+                       filter->status = 2;
+                       filter->cache = (c1 << 8) | c;
+                       return c;
+               } else if (c1 >= 0x90 && c1 <= 0xe3 && c >= 0x30 && c <= 0x39) { /* 4 byte range: Unicode 16 planes */
+                       filter->status = 2;
+                       filter->cache = (c1 << 8) | c;
+                       return c;
+               } else if (((c1 >= 0xaa && c1 <= 0xaf) || (c1 >= 0xf8 && c1 <= 0xfe)) &&
+                                  (c >= 0xa1 && c <= 0xfe)) { /* UDA part1,2: U+E000-U+E4C5 */
+                       w = 94*(c1 >= 0xf8 ? c1 - 0xf2 : c1 - 0xaa) + (c - 0xa1) + 0xe000;
+                       CK((*filter->output_function)(w, filter->data));
+               } else if (c1 >= 0xa1 && c1 <= 0xa7 && c >= 0x40 && c < 0xa1 && c != 0x7f) { /* UDA part3 : U+E4C6-U+E765*/
+                       w = 96*(c1 - 0xa1) + c - (c >= 0x80 ? 0x41 : 0x40) + 0xe4c6;
+                       CK((*filter->output_function)(w, filter->data));
+               } 
+
+               if (w <= 0) {
+                       c2 = (c1 << 8) | c;
+                       for (k = 0; k < mbfl_gb18030_pua_tbl_max; k++) {
+                               if (c2 >= mbfl_gb18030_pua_tbl[k][2] && 
+                                       c2 <= mbfl_gb18030_pua_tbl[k][2] +  mbfl_gb18030_pua_tbl[k][1] -  mbfl_gb18030_pua_tbl[k][0]) {
+                                       w = c2 -  mbfl_gb18030_pua_tbl[k][2] + mbfl_gb18030_pua_tbl[k][0];
+                                       CK((*filter->output_function)(w, filter->data));
+                                       break;
+                               }
+                       }
+               }
+
+               if (w <= 0) {
+                       if ((c1 >= 0xa1 && c1 <= 0xa9 && c >= 0xa1 && c <= 0xfe) ||
+                               (c1 >= 0xb0 && c1 <= 0xf7 && c >= 0xa1 && c <= 0xfe) ||
+                               (c1 >= 0x81 && c1 <= 0xa0 && c >= 0x40 && c <= 0xfe && c != 0x7f) ||
+                               (c1 >= 0xaa && c1 <= 0xfe && c >= 0x40 && c <= 0xa0 && c != 0x7f) ||
+                               (c1 >= 0xa8 && c1 <= 0xa9 && c >= 0x40 && c <= 0xa0 && c != 0x7f)) {
+                               w = (c1 - 0x81)*192 + (c - 0x40);
+                               if (w >= 0 && w < cp936_ucs_table_size) {
+                                       w = cp936_ucs_table[w];
+                               } else {
+                                       w = 0;
+                               }
+                               if (w <= 0) {
+                                       w = (c1 << 8) | c;
+                                       w &= MBFL_WCSPLANE_MASK;
+                                       w |= MBFL_WCSPLANE_GB18030;
+                               }
+                               CK((*filter->output_function)(w, filter->data));
+                       } else if ((c >= 0 && c < 0x21) || c == 0x7f) {         /* CTLs */
+                               CK((*filter->output_function)(c, filter->data));
+                       } else {
+                               w = (c1 << 8) | c;
+                               w &= MBFL_WCSGROUP_MASK;
+                               w |= MBFL_WCSGROUP_THROUGH;
+                               CK((*filter->output_function)(w, filter->data));
+                       }
+               }
+               break;
+       case 2: /* fbcs third byte */
+               c1 = (filter->cache >> 8) & 0xff;
+               c2 = filter->cache & 0xff;
+               filter->status = 0;
+               filter->cache = 0;
+               if (((c1 >= 0x81 && c1 <= 0x84) || (c1 >= 0x90 && c1 <= 0xe3)) &&
+                       c2 >= 0x30 && c2 <= 0x39 && c >= 0x81 && c <= 0xfe) {
+                       filter->cache = (c1 << 16) | (c2 << 8) | c;
+                       filter->status = 3;
+               } else {
+                       w = (c1 << 16) | (c2 << 8) | c;
+                       w &= MBFL_WCSGROUP_MASK;
+                       w |= MBFL_WCSGROUP_THROUGH;
+                       CK((*filter->output_function)(w, filter->data));                        
+               }
+               break;
+
+       case 3: /* fbcs fourth byte */
+               c1 = (filter->cache >> 16) & 0xff;
+               c2 = (filter->cache >> 8) & 0xff;
+               c3 = filter->cache & 0xff;
+               filter->status = 0;
+               filter->cache = 0;
+               if (((c1 >= 0x81 && c1 <= 0x84) || (c1 >= 0x90 && c1 <= 0xe3)) &&
+                       c2 >= 0x30 && c2 <= 0x39 && c3 >= 0x81 && c3 <= 0xfe && c >= 0x30 && c <= 0x39) {
+                       if (c1 >= 0x90 && c1 <= 0xe3) {
+                               w = ((c1 - 0x90)*10 + (c2 - 0x30)*126 + (c3 - 0x81))*10 + (c - 0x30) + 0x10000;
+                       } else { /* Unicode BMP */
+                               w = (((c1 - 0x81)*10 + (c2 - 0x30))*126 + (c3 - 0x81))*10 + (c - 0x30);
+                               if (w >= 0 && w <= 39419) {
+                                       k = mbfl_bisec_srch(w, mbfl_gb2uni_tbl, mbfl_gb_uni_max);
+                                       if (k<0) {
+                                               /* error */
+                                               w = (c1 << 24) | (c2 << 16) | (c3 << 8) | c;
+                                               w &= MBFL_WCSGROUP_MASK;
+                                               w |= MBFL_WCSGROUP_THROUGH;
+                                               CK((*filter->output_function)(w, filter->data));                        
+                                               return c;
+                                       }
+                                       w += mbfl_gb_uni_ofst[k];
+                               } else {
+                                       w = (c1 << 24) | (c2 << 16) | (c3 << 8) | c;
+                                       w &= MBFL_WCSGROUP_MASK;
+                                       w |= MBFL_WCSGROUP_THROUGH;
+                                       CK((*filter->output_function)(w, filter->data));                        
+                                       return c;
+                               }
+                       }
+                       CK((*filter->output_function)(w, filter->data));
+               } else {
+                       w = (c1 << 24) | (c2 << 16) | (c3 << 8) | c;
+                       w &= MBFL_WCSGROUP_MASK;
+                       w |= MBFL_WCSGROUP_THROUGH;
+                       CK((*filter->output_function)(w, filter->data));                        
+               }
+               break;
+
+       default:
+               filter->status = 0;
+               break;
+       }
+
+       return c;
+}
+
+/*
+ * wchar => GB18030
+ */
+int
+mbfl_filt_conv_wchar_gb18030(int c, mbfl_convert_filter *filter)
+{
+       int k, k1, k2;
+       int c1, s, s1 = 0;
+
+       s = 0;
+       if (c >= ucs_a1_cp936_table_min && c < ucs_a1_cp936_table_max) {
+               s = ucs_a1_cp936_table[c - ucs_a1_cp936_table_min];
+       } else if (c >= ucs_a2_cp936_table_min && c < ucs_a2_cp936_table_max) {
+               s = ucs_a2_cp936_table[c - ucs_a2_cp936_table_min];
+       } else if (c >= ucs_a3_cp936_table_min && c < ucs_a3_cp936_table_max) {
+               s = ucs_a3_cp936_table[c - ucs_a3_cp936_table_min];
+       } else if (c >= ucs_i_cp936_table_min && c < ucs_i_cp936_table_max) {
+               s = ucs_i_cp936_table[c - ucs_i_cp936_table_min];
+       } else if (c >= ucs_ci_cp936_table_min && c < ucs_ci_cp936_table_max) {
+               s = ucs_ci_cp936_table[c - ucs_ci_cp936_table_min];
+       } else if (c >= ucs_cf_cp936_table_min && c < ucs_cf_cp936_table_max) {
+               s = ucs_cf_cp936_table[c - ucs_cf_cp936_table_min];
+       } else if (c >= ucs_sfv_cp936_table_min && c < ucs_sfv_cp936_table_max) {
+               s = ucs_sfv_cp936_table[c - ucs_sfv_cp936_table_min];
+       } else if (c >= ucs_hff_cp936_table_min && c < ucs_hff_cp936_table_max) {
+               s = ucs_hff_cp936_table[c - ucs_hff_cp936_table_min];
+       }
+
+       if (c == 0x20ac) { /* euro-sign */
+               s = 0xa2e3;
+       }
+
+       if (s <= 0 && c >= mbfl_gb18030_c_tbl_key[0] && 
+               c <= mbfl_gb18030_c_tbl_key[mbfl_gb18030_c_tbl_max-1]) {
+               k1 = mbfl_bisec_srch2(c, mbfl_gb18030_c_tbl_key, mbfl_gb18030_c_tbl_max);
+               if (k1 >= 0) {
+                       s = mbfl_gb18030_c_tbl_val[k1];
+               }
+       }
+
+       if (c >= 0xe000 && c <= 0xe864) { /* PUA */
+               if (c < 0xe766) {
+                       if (c < 0xe4c6) {
+                               c1 = c - 0xe000;
+                               s = (c1 % 94) + 0xa1; c1 /= 94;
+                               s |= (c1 < 0x06 ? c1 + 0xaa : c1 + 0xf2) << 8;
+                       } else {
+                               c1 = c - 0xe4c6;
+                               s = ((c1 / 96) + 0xa1) << 8; c1 %= 96;
+                               s |= c1 + (c1 >= 0x3f ? 0x41 : 0x40);                   
+                       }
+               } else {
+                       /* U+E766..U+E864 */
+                       k1 = 0; k2 = mbfl_gb18030_pua_tbl_max;
+                       while (k1 < k2) {
+                               k = (k1 + k2) >> 1;
+                               if (c < mbfl_gb18030_pua_tbl[k][0]) {
+                                       k2 = k;
+                               } else if (c > mbfl_gb18030_pua_tbl[k][1]) {
+                                       k1 = k + 1;
+                               } else {
+                                       s = c - mbfl_gb18030_pua_tbl[k][0] + mbfl_gb18030_pua_tbl[k][2];
+                                       break;
+                               }
+                       }
+               }
+       } 
+
+       if (s <= 0 && c >= 0x0080 && c <= 0xffff) { /* BMP */
+               s = mbfl_bisec_srch(c, mbfl_uni2gb_tbl, mbfl_gb_uni_max);
+               if (s >= 0) {
+                       c1 = c - mbfl_gb_uni_ofst[s];
+                       s = (c1 % 10) + 0x30; c1 /= 10;
+                       s |= ((c1 % 126) + 0x81) << 8; c1 /= 126;
+                       s |= ((c1 % 10) + 0x30) << 16; c1 /= 10;
+                       s1 = c1 + 0x81;
+               }
+       } else if (c >= 0x10000 && c <= 0x10ffff) { /* Code set 3: Unicode U+10000..U+10FFFF */
+               c1 = c - 0x10000;
+               s = (c1 % 10) + 0x30; c1 /= 10;
+               s |= ((c1 % 126) + 0x81) << 8; c1 /= 126;
+               s |= ((c1 % 10) + 0x30) << 16; c1 /= 10;
+               s1 = c1 + 0x90;
+       }
+
+       if (s <= 0) {
+               c1 = c & ~MBFL_WCSPLANE_MASK;
+               if (c1 == MBFL_WCSPLANE_WINCP936) {
+                       s = c & MBFL_WCSPLANE_MASK;
+               }
+               if (c == 0) {
+                       s = 0;
+               } else if (s <= 0) {
+                       s = -1;
+               }
+       }
+       if (s >= 0) {
+               if (s <= 0x80) {        /* latin */
+                       CK((*filter->output_function)(s, filter->data));
+               } else if (s1 > 0) { /* fbcs */
+                       CK((*filter->output_function)(s1 & 0xff, filter->data));
+                       CK((*filter->output_function)((s >> 16) & 0xff, filter->data));
+                       CK((*filter->output_function)((s >> 8) & 0xff, filter->data));
+                       CK((*filter->output_function)(s & 0xff, filter->data));
+               } else { /* dbcs */
+                       CK((*filter->output_function)((s >> 8) & 0xff, filter->data));
+                       CK((*filter->output_function)(s & 0xff, filter->data));
+               }
+       } else {
+               if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
+                       CK(mbfl_filt_conv_illegal_output(c, filter));
+               }
+       }
+
+       return c;
+}
+
+static int mbfl_filt_ident_gb18030(int c, mbfl_identify_filter *filter)
+{
+       int c1;
+       
+       c1 = (filter->status >> 8) & 0xff;
+       filter->status &= 0xff;
+
+       if (filter->status == 0) {
+               if (c <= 0x80 || c == 0xff) {
+                       filter->status = 0;
+               } else {
+                       filter->status = 1;
+                       filter->status |= (c << 8);
+               }
+       } else if (filter->status == 1) { /* dbcs/fbcs 2nd byte */
+               if (((c1 >= 0x81 && c1 <= 0x84) || (c1 >= 0x90 && c1 <= 0xe3)) && c >= 0x30 && c <= 0x39) { /* fbcs */
+                       filter->status = 2;
+               } else if (((c1 >= 0xaa && c1 <= 0xaf) || (c1 >= 0xf8 && c1 <= 0xfe)) && (c >= 0xa1 && c <= 0xfe)) {
+                       filter->status = 0; /* UDA part 1,2 */
+               } else if (c1 >= 0xa1 && c1 <= 0xa7 && c >= 0x40 && c < 0xa1 && c != 0x7f) {
+                       filter->status = 0; /* UDA part 3 */
+               } else if ((c1 >= 0xa1 && c1 <= 0xa9 && c >= 0xa1 && c <= 0xfe) ||
+                                  (c1 >= 0xb0 && c1 <= 0xf7 && c >= 0xa1 && c <= 0xfe) ||
+                                  (c1 >= 0x81 && c1 <= 0xa0 && c >= 0x40 && c <= 0xfe && c != 0x7f) ||
+                                  (c1 >= 0xaa && c1 <= 0xfe && c >= 0x40 && c <= 0xa0 && c != 0x7f) ||
+                                  (c1 >= 0xa8 && c1 <= 0xa9 && c >= 0x40 && c <= 0xa0 && c != 0x7f)) {
+                       filter->status = 0; /* DBCS */
+               } else {
+                       filter->flag = 1; /* bad */
+                       filter->status = 0;                     
+               }
+       } else if (filter->status == 2) { /* fbcs 3rd byte */
+               if (c > 0x80 && c < 0xff) {
+                       filter->status = 3;
+               } else {
+                       filter->flag = 1; /* bad */
+                       filter->status = 0;
+               }
+       } else if (filter->status == 3) { /* fbcs 4th byte */
+               if (c >= 0x30 && c < 0x40) {
+                       filter->status = 0;
+               } else {
+                       filter->flag = 1; /* bad */
+                       filter->status = 0;
+               }               
+       } else {                                                        /* bad */
+               filter->flag = 1;
+       }
+
+       return c;
+}
+
+
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_gb18030.h b/ext/mbstring/libmbfl/filters/mbfilter_gb18030.h
new file mode 100644 (file)
index 0000000..e182a39
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * the source code included in this files was separated from mbfilter_cn.h
+ * by moriyoshi koizumi <moriyoshi@php.net> on 4 dec 2002.
+ *
+ */
+
+#ifndef MBFL_MBFILTER_GB18030_H
+#define MBFL_MBFILTER_GB18030_H
+
+#include "mbfilter.h"
+
+extern const mbfl_encoding mbfl_encoding_gb18030;
+extern const struct mbfl_identify_vtbl vtbl_identify_gb18030;
+extern const struct mbfl_convert_vtbl vtbl_gb18030_wchar;
+extern const struct mbfl_convert_vtbl vtbl_wchar_gb18030;
+
+int mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter);
+int mbfl_filt_conv_wchar_gb18030(int c, mbfl_convert_filter *filter);
+#endif /* MBFL_MBFILTER_GB18030_H */
index 0b895cd7a6e23be15e66c2e96bbdbeb4327aae8a..42a162fa3ac9a76d96b2d0373ceb9eb15c1f63a2 100644 (file)
@@ -376,9 +376,6 @@ mbfl_filt_conv_sjis_mac_wchar(int c, mbfl_convert_filter *filter)
                                                                w = 0xf87f;
                                                        } else if (w & 0x80000) {
                                                                w = 0x20dd;
-                                                       } else if (w & 0xF0000) {
-                                                               // TBD
-                                                               w = 0;
                                                        } else {
                                                                w = 0;
                                                        }
index 9ae8ae3669e57eb8e347a448712e53bd472b2774..f5fece402b409824a725db77beb4b64ab9140362 100644 (file)
@@ -877,7 +877,7 @@ const unsigned short cp936_ucs_table[] = {
 0x2477,0x2478,0x2479,0x247a,0x247b,0x247c,0x247d,0x247e,
 0x247f,0x2480,0x2481,0x2482,0x2483,0x2484,0x2485,0x2486,
 0x2487,0x2460,0x2461,0x2462,0x2463,0x2464,0x2465,0x2466,
-0x2467,0x2468,0x2469,0x0000,0x0000,0x3220,0x3221,0x3222,
+0x2467,0x2468,0x2469,0x20ac,0x0000,0x3220,0x3221,0x3222,
 0x3223,0x3224,0x3225,0x3226,0x3227,0x3228,0x3229,0x0000,
 0x0000,0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,
 0x2167,0x2168,0x2169,0x216a,0x216b,0x0000,0x0000,0x0000,
@@ -1022,7 +1022,7 @@ const unsigned short cp936_ucs_table[] = {
 0x0000,0x0101,0x00e1,0x01ce,0x00e0,0x0113,0x00e9,0x011b,
 0x00e8,0x012b,0x00ed,0x01d0,0x00ec,0x014d,0x00f3,0x01d2,
 0x00f2,0x016b,0x00fa,0x01d4,0x00f9,0x01d6,0x01d8,0x01da,
-0x01dc,0x00fc,0x00ea,0x0251,0x0000,0x0144,0x0148,0x0000,
+0x01dc,0x00fc,0x00ea,0x0251,0x0000,0x0144,0x0148,0x01f9,
 0x0261,0x0000,0x0000,0x0000,0x0000,0x3105,0x3106,0x3107,
 0x3108,0x3109,0x310a,0x310b,0x310c,0x310d,0x310e,0x310f,
 0x3110,0x3111,0x3112,0x3113,0x3114,0x3115,0x3116,0x3117,
@@ -1041,8 +1041,8 @@ const unsigned short cp936_ucs_table[] = {
 0xfe51,0xfe52,0xfe54,0xfe55,0xfe56,0xfe57,0xfe59,0xfe5a,
 0xfe5b,0xfe5c,0xfe5d,0xfe5e,0xfe5f,0xfe60,0xfe61,0x0000,
 0xfe62,0xfe63,0xfe64,0xfe65,0xfe66,0xfe68,0xfe69,0xfe6a,
-0xfe6b,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3007,0x0000,
+0xfe6b,0x303e,0x2ff0,0x2ff1,0x2ff2,0x2ff3,0x2ff4,0x2ff5,
+0x2ff6,0x2ff7,0x2ff8,0x2ff9,0x2ffa,0x2ffb,0x3007,0x0000,
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 0x0000,0x0000,0x0000,0x0000,0x2500,0x2501,0x2502,0x2503,
 0x2504,0x2505,0x2506,0x2507,0x2508,0x2509,0x250a,0x250b,
@@ -3158,7 +3158,18 @@ const unsigned short cp936_ucs_table[] = {
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 /* 0xfe00 */
 0xfa0c,0xfa0d,0xfa0e,0xfa0f,0xfa11,0xfa13,0xfa14,0xfa18,
-0xfa1f,0xfa20,0xfa21,0xfa23,0xfa24,0xfa27,0xfa28,0xfa29};
+0xfa1f,0xfa20,0xfa21,0xfa23,0xfa24,0xfa27,0xfa28,0xfa29,
+0x2e81,0x0000,0x0000,0x0000,0x2e84,0x3473,0x3447,0x2e88,
+0x2e8b,0x0000,0x359e,0x361a,0x360e,0x2e8c,0x2e97,0x396e,
+0x3918,0x0000,0x39cf,0x39df,0x3a73,0x39d0,0x0000,0x0000,
+0x3b4e,0x3c6e,0x3ce0,0x2ea7,0x0000,0x0000,0x2eaa,0x4056,
+0x415f,0x2eae,0x4337,0x2eb3,0x2eb6,0x2eb7,0x0000,0x43b1,
+0x43ac,0x2ebb,0x43dd,0x44d6,0x4661,0x464c,0x0000,0x0000,
+0x4723,0x4729,0x477c,0x478d,0x2eca,0x4947,0x497a,0x497d,
+0x4982,0x4983,0x4985,0x4986,0x499f,0x499b,0x49b7,0x49b6,
+0x0000,0x0000,0x4ca3,0x4c9f,0x4ca0,0x4ca1,0x4c77,0x4ca2,
+0x4d13,0x4d14,0x4d15,0x4d16,0x4d17,0x4d18,0x4d19,0x4dae,
+};
 
 const int cp936_ucs_table_size = (sizeof(cp936_ucs_table)/sizeof(unsigned short));
 
@@ -3229,7 +3240,7 @@ const unsigned short ucs_a1_cp936_table[] = {
 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,0x0000,0x0000,0x0000,0x0000,
+0x0000,0xa8bf,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 /* 0x0200 */
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
@@ -3580,8 +3591,9 @@ const unsigned short ucs_a3_cp936_table[] = {
 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,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
+0xa98a,0xa98b,0xa98c,0xa98d,0xa98e,0xa98f,0xa990,0xa991,
+0xa992,0xa993,0xa994,0xa995,0x0000,0x0000,0x0000,0x0000,
+/* 0x3000 */
 0xa1a1,0xa1a2,0xa1a3,0xa1a8,0x0000,0xa1a9,0xa965,0xa996,
 0xa1b4,0xa1b5,0xa1b6,0xa1b7,0xa1b8,0xa1b9,0xa1ba,0xa1bb,
 0xa1be,0xa1bf,0xa893,0xa1fe,0xa1b2,0xa1b3,0xa1bc,0xa1bd,
@@ -3589,7 +3601,7 @@ const unsigned short ucs_a3_cp936_table[] = {
 0x0000,0xa940,0xa941,0xa942,0xa943,0xa944,0xa945,0xa946,
 0xa947,0xa948,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,0xa989,0x0000,
 0x0000,0xa4a1,0xa4a2,0xa4a3,0xa4a4,0xa4a5,0xa4a6,0xa4a7,
 0xa4a8,0xa4a9,0xa4aa,0xa4ab,0xa4ac,0xa4ad,0xa4ae,0xa4af,
 0xa4b0,0xa4b1,0xa4b2,0xa4b3,0xa4b4,0xa4b5,0xa4b6,0xa4b7,
@@ -3723,6 +3735,8 @@ const unsigned short ucs_i_cp936_table[] = {
 /* 0x4d00 */
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
+0x0000,0x0000,0x0000,0xfe98,0xfe99,0xfe9a,0xfe9b,0xfe9c,
+0xfe9d,0xfe9e,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,0x0000,0x0000,
@@ -3740,9 +3754,7 @@ const unsigned short ucs_i_cp936_table[] = {
 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,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,0xfe9f,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,
diff --git a/ext/mbstring/libmbfl/filters/unicode_table_gb18030.h b/ext/mbstring/libmbfl/filters/unicode_table_gb18030.h
new file mode 100644 (file)
index 0000000..7c38045
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file: Rui Hirokawa <hirokawa@php.net>
+ *
+ */
+
+#ifndef UNICODE_TABLE_GB18030_H
+#define UNICODE_TABLE_GB18030_H
+
+static const unsigned short mbfl_gb18030_c_tbl_val[58] =
+{
+       0xfe50,0xfe54,0xfe57,0xfe58,0xfe5d,0xfe5e,0xfe6b,0xfe6e,
+       0xfe71,0xfe73,0xfe74,0xfe75,0xfe79,0xfe84,0xfe56,0xfe55,
+       0xfe5a,0xfe5c,0xfe5b,0xfe60,0xfe5f,0xfe62,0xfe65,0xfe63,
+       0xfe64,0xfe68,0xfe69,0xfe6a,0xfe6f,0xfe70,0xfe72,0xfe78,
+       0xfe77,0xfe7a,0xfe7b,0xfe7d,0xfe7c,0xfe80,0xfe81,0xfe82,
+       0xfe83,0xfe85,0xfe86,0xfe87,0xfe88,0xfe89,0xfe8a,0xfe8b,
+       0xfe8d,0xfe8c,0xfe8f,0xfe8e,0xfe96,0xfe93,0xfe94,0xfe95,
+       0xfe97,0xfe92,
+};
+
+static const unsigned short mbfl_gb18030_c_tbl_key[58] =
+{
+       0x2e81,0x2e84,0x2e88,0x2e8b,0x2e8c,0x2e97,0x2ea7,0x2eaa,
+       0x2eae,0x2eb3,0x2eb6,0x2eb7,0x2ebb,0x2eca,0x3447,0x3473,
+       0x359e,0x360e,0x361a,0x3918,0x396e,0x39cf,0x39d0,0x39df,
+       0x3a73,0x3b4e,0x3c6e,0x3ce0,0x4056,0x415f,0x4337,0x43ac,
+       0x43b1,0x43dd,0x44d6,0x464c,0x4661,0x4723,0x4729,0x477c,
+       0x478d,0x4947,0x497a,0x497d,0x4982,0x4983,0x4985,0x4986,
+       0x499b,0x499f,0x49b6,0x49b7,0x4c77,0x4c9f,0x4ca0,0x4ca1,
+       0x4ca2,0x4ca3,
+};
+
+static const int mbfl_gb18030_c_tbl_max = sizeof(mbfl_gb18030_c_tbl_key)/sizeof(unsigned short);
+
+static const unsigned short mbfl_gb18030_pua_tbl[][3] = {
+       {0xe766, 0xe76b, 0xa2ab},
+       {0xe76d, 0xe76d, 0xa2e4},
+       {0xe76e, 0xe76f, 0xa2ef},
+       {0xe770, 0xe771, 0xa2fd},
+       {0xe772, 0xe77c, 0xa4f4},
+       {0xe77d, 0xe784, 0xa5f7},
+       {0xe785, 0xe78c, 0xa6b9},
+       {0xe78d, 0xe793, 0xa6d9},
+       {0xe794, 0xe795, 0xa6ec},
+       {0xe796, 0xe796, 0xa6f3},
+       {0xe797, 0xe79f, 0xa6f6},
+       {0xe7a0, 0xe7ae, 0xa7c2},
+       {0xe7af, 0xe7bb, 0xa7f2},
+       {0xe7bc, 0xe7c6, 0xa896},
+       {0xe7c7, 0xe7c7, 0xa8bc},
+       {0xe7c9, 0xe7cc, 0xa8c1},
+       {0xe7cd, 0xe7e1, 0xa8ea},
+       {0xe7e2, 0xe7e2, 0xa958},
+       {0xe7e3, 0xe7e3, 0xa95b},
+       {0xe7e4, 0xe7e6, 0xa95d},
+       {0xe7f4, 0xe800, 0xa997},
+       {0xe801, 0xe80f, 0xa9f0},
+       {0xe810, 0xe814, 0xd7fa},
+       {0xe816, 0xe818, 0xfe51},
+       {0xe81e, 0xe81e, 0xfe59},
+       {0xe826, 0xe826, 0xfe61},
+       {0xe82b, 0xe82c, 0xfe66},
+       {0xe831, 0xe832, 0xfe6c},
+       {0xe83b, 0xe83b, 0xfe76},
+       {0xe843, 0xe843, 0xfe7e},
+       {0xe854, 0xe855, 0xfe90},
+       {0xe864, 0xe864, 0xfea0},
+};
+
+static const int mbfl_gb18030_pua_tbl_max = sizeof(mbfl_gb18030_pua_tbl)/(sizeof(unsigned short)*3);
+
+static const unsigned short mbfl_gb2uni_tbl[] = {
+0x0000, 0x0023, 0x0024, 0x0025, 0x0026, 0x002c, 0x002d, 0x0031, 
+0x0032, 0x0050, 0x0051, 0x0058, 0x0059, 0x005e, 0x005f, 0x005f, 
+0x0060, 0x0063, 0x0064, 0x0066, 0x0067, 0x0067, 0x0068, 0x0068, 
+0x0069, 0x006c, 0x006d, 0x007d, 0x007e, 0x0084, 0x0085, 0x0093, 
+0x0094, 0x00ab, 0x00ac, 0x00ae, 0x00af, 0x00b2, 0x00b3, 0x00cf, 
+0x00d0, 0x0131, 0x0132, 0x0132, 0x0133, 0x0133, 0x0134, 0x0134, 
+0x0135, 0x0135, 0x0136, 0x0136, 0x0137, 0x0137, 0x0138, 0x0138, 
+0x0139, 0x0154, 0x0155, 0x01ab, 0x01ac, 0x01ba, 0x01bb, 0x021f, 
+0x0220, 0x0220, 0x0221, 0x022d, 0x022e, 0x02e4, 0x02e5, 0x02e5, 
+0x02e6, 0x02ec, 0x02ed, 0x02ed, 0x02ee, 0x0324, 0x0325, 0x0332, 
+0x0333, 0x0333, 0x0334, 0x1ef1, 0x1ef2, 0x1ef3, 0x1ef4, 0x1ef4, 
+0x1ef5, 0x1ef6, 0x1ef7, 0x1efd, 0x1efe, 0x1f06, 0x1f07, 0x1f07, 
+0x1f08, 0x1f08, 0x1f09, 0x1f0d, 0x1f0e, 0x1f7d, 0x1f7e, 0x1fd3, 
+0x1fd4, 0x1fd4, 0x1fd5, 0x1fd7, 0x1fd8, 0x1fe3, 0x1fe4, 0x1fed, 
+0x1fee, 0x202b, 0x202c, 0x202f, 0x2030, 0x2045, 0x2046, 0x2047, 
+0x2048, 0x20b5, 0x20b6, 0x20bb, 0x20bc, 0x20bc, 0x20bd, 0x20bf, 
+0x20c0, 0x20c3, 0x20c4, 0x20c5, 0x20c6, 0x20c7, 0x20c8, 0x20c8, 
+0x20c9, 0x20c9, 0x20ca, 0x20cb, 0x20cc, 0x20d0, 0x20d1, 0x20d5, 
+0x20d6, 0x20df, 0x20e0, 0x20e2, 0x20e3, 0x20e7, 0x20e8, 0x20f4, 
+0x20f5, 0x20f6, 0x20f7, 0x20fc, 0x20fd, 0x2121, 0x2122, 0x2124, 
+0x2125, 0x212f, 0x2130, 0x2148, 0x2149, 0x219a, 0x219b, 0x22e7, 
+0x22e8, 0x22f1, 0x22f2, 0x2355, 0x2356, 0x2359, 0x235a, 0x2366, 
+0x2367, 0x2369, 0x236a, 0x2373, 0x2374, 0x2383, 0x2384, 0x238b, 
+0x238c, 0x2393, 0x2394, 0x2396, 0x2397, 0x2398, 0x2399, 0x23aa, 
+0x23ab, 0x23c9, 0x23ca, 0x23cb, 0x23cc, 0x2401, 0x2402, 0x2402, 
+0x2403, 0x2c40, 0x2c41, 0x2c42, 0x2c43, 0x2c45, 0x2c46, 0x2c47, 
+0x2c48, 0x2c51, 0x2c52, 0x2c60, 0x2c61, 0x2c62, 0x2c63, 0x2c65, 
+0x2c66, 0x2c69, 0x2c6a, 0x2c6b, 0x2c6c, 0x2c6e, 0x2c6f, 0x2c7c, 
+0x2c7d, 0x2da1, 0x2da2, 0x2da5, 0x2da6, 0x2da6, 0x2da7, 0x2dab, 
+0x2dac, 0x2dad, 0x2dae, 0x2dc1, 0x2dc2, 0x2dc3, 0x2dc4, 0x2dca, 
+0x2dcb, 0x2dcc, 0x2dcd, 0x2dd1, 0x2dd2, 0x2dd7, 0x2dd8, 0x2ecd, 
+0x2ece, 0x2ed4, 0x2ed5, 0x2f45, 0x2f46, 0x302f, 0x3030, 0x303b, 
+0x303c, 0x303d, 0x303e, 0x305f, 0x3060, 0x3068, 0x3069, 0x306a, 
+0x306b, 0x306c, 0x306d, 0x30dd, 0x30de, 0x3108, 0x3109, 0x3232, 
+0x3233, 0x32a1, 0x32a2, 0x32ac, 0x32ad, 0x35a9, 0x35aa, 0x35fe, 
+0x35ff, 0x365e, 0x365f, 0x366c, 0x366d, 0x36ff, 0x3700, 0x37d9, 
+0x37da, 0x38f8, 0x38f9, 0x3969, 0x396a, 0x3cde, 0x3cdf, 0x3de6, 
+0x3de7, 0x3fbd, 0x3fbe, 0x4031, 0x4032, 0x4035, 0x4036, 0x4060, 
+0x4061, 0x4158, 0x4159, 0x42cd, 0x42ce, 0x42e1, 0x42e2, 0x43a2, 
+0x43a3, 0x43a7, 0x43a8, 0x43f9, 0x43fa, 0x4409, 0x440a, 0x45c2, 
+0x45c3, 0x45f4, 0x45f5, 0x45f6, 0x45f7, 0x45fa, 0x45fb, 0x45fb, 
+0x45fc, 0x460f, 0x4610, 0x4612, 0x4613, 0x4628, 0x4629, 0x48e7, 
+0x48e8, 0x490e, 0x490f, 0x497d, 0x497e, 0x4a11, 0x4a12, 0x4a62, 
+0x4a63, 0x82bc, 0x82bd, 0x82bd, 0x82be, 0x82be, 0x82bf, 0x82cb, 
+0x82cc, 0x82cc, 0x82cd, 0x82d1, 0x82d2, 0x82d8, 0x82d9, 0x82dc, 
+0x82dd, 0x82e0, 0x82e1, 0x82e8, 0x82e9, 0x82ef, 0x82f0, 0x82ff, 
+0x8300, 0x830d, 0x830e, 0x93d4, 0x93d5, 0x9420, 0x9421, 0x943b, 
+0x943c, 0x948c, 0x948d, 0x9495, 0x9496, 0x94af, 0x94b0, 0x94b0, 
+0x94b1, 0x94b1, 0x94b2, 0x94b4, 0x94b5, 0x94ba, 0x94bb, 0x94bb, 
+0x94bc, 0x94bd, 0x94be, 0x98c3, 0x98c4, 0x98c4, 0x98c5, 0x98c8, 
+0x98c9, 0x98c9, 0x98ca, 0x98ca, 0x98cb, 0x98cb, 0x98cc, 0x9960, 
+0x9961, 0x99e1, 0x99e2, 0x99fb, 
+};
+
+static const unsigned short mbfl_uni2gb_tbl[] = {
+0x0080, 0x00a3, 0x00a5, 0x00a6, 0x00a9, 0x00af, 0x00b2, 0x00b6, 
+0x00b8, 0x00d6, 0x00d8, 0x00df, 0x00e2, 0x00e7, 0x00eb, 0x00eb, 
+0x00ee, 0x00f1, 0x00f4, 0x00f6, 0x00f8, 0x00f8, 0x00fb, 0x00fb, 
+0x00fd, 0x0100, 0x0102, 0x0112, 0x0114, 0x011a, 0x011c, 0x012a, 
+0x012c, 0x0143, 0x0145, 0x0147, 0x0149, 0x014c, 0x014e, 0x016a, 
+0x016c, 0x01cd, 0x01cf, 0x01cf, 0x01d1, 0x01d1, 0x01d3, 0x01d3, 
+0x01d5, 0x01d5, 0x01d7, 0x01d7, 0x01d9, 0x01d9, 0x01db, 0x01db, 
+0x01dd, 0x01f8, 0x01fa, 0x0250, 0x0252, 0x0260, 0x0262, 0x02c6, 
+0x02c8, 0x02c8, 0x02cc, 0x02d8, 0x02da, 0x0390, 0x03a2, 0x03a2, 
+0x03aa, 0x03b0, 0x03c2, 0x03c2, 0x03ca, 0x0400, 0x0402, 0x040f, 
+0x0450, 0x0450, 0x0452, 0x200f, 0x2011, 0x2012, 0x2017, 0x2017, 
+0x201a, 0x201b, 0x201e, 0x2024, 0x2027, 0x202f, 0x2031, 0x2031, 
+0x2034, 0x2034, 0x2036, 0x203a, 0x203c, 0x20ab, 0x20ad, 0x2102, 
+0x2104, 0x2104, 0x2106, 0x2108, 0x210a, 0x2115, 0x2117, 0x2120, 
+0x2122, 0x215f, 0x216c, 0x216f, 0x217a, 0x218f, 0x2194, 0x2195, 
+0x219a, 0x2207, 0x2209, 0x220e, 0x2210, 0x2210, 0x2212, 0x2214, 
+0x2216, 0x2219, 0x221b, 0x221c, 0x2221, 0x2222, 0x2224, 0x2224, 
+0x2226, 0x2226, 0x222c, 0x222d, 0x222f, 0x2233, 0x2238, 0x223c, 
+0x223e, 0x2247, 0x2249, 0x224b, 0x224d, 0x2251, 0x2253, 0x225f, 
+0x2262, 0x2263, 0x2268, 0x226d, 0x2270, 0x2294, 0x2296, 0x2298, 
+0x229a, 0x22a4, 0x22a6, 0x22be, 0x22c0, 0x2311, 0x2313, 0x245f, 
+0x246a, 0x2473, 0x249c, 0x24ff, 0x254c, 0x254f, 0x2574, 0x2580, 
+0x2590, 0x2592, 0x2596, 0x259f, 0x25a2, 0x25b1, 0x25b4, 0x25bb, 
+0x25be, 0x25c5, 0x25c8, 0x25ca, 0x25cc, 0x25cd, 0x25d0, 0x25e1, 
+0x25e6, 0x2604, 0x2607, 0x2608, 0x260a, 0x263f, 0x2641, 0x2641, 
+0x2643, 0x2e80, 0x2e82, 0x2e83, 0x2e85, 0x2e87, 0x2e89, 0x2e8a, 
+0x2e8d, 0x2e96, 0x2e98, 0x2ea6, 0x2ea8, 0x2ea9, 0x2eab, 0x2ead, 
+0x2eaf, 0x2eb2, 0x2eb4, 0x2eb5, 0x2eb8, 0x2eba, 0x2ebc, 0x2ec9, 
+0x2ecb, 0x2fef, 0x2ffc, 0x2fff, 0x3004, 0x3004, 0x3018, 0x301c, 
+0x301f, 0x3020, 0x302a, 0x303d, 0x303f, 0x3040, 0x3094, 0x309a, 
+0x309f, 0x30a0, 0x30f7, 0x30fb, 0x30ff, 0x3104, 0x312a, 0x321f, 
+0x322a, 0x3230, 0x3232, 0x32a2, 0x32a4, 0x338d, 0x3390, 0x339b, 
+0x339f, 0x33a0, 0x33a2, 0x33c3, 0x33c5, 0x33cd, 0x33cf, 0x33d0, 
+0x33d3, 0x33d4, 0x33d6, 0x3446, 0x3448, 0x3472, 0x3474, 0x359d, 
+0x359f, 0x360d, 0x360f, 0x3619, 0x361b, 0x3917, 0x3919, 0x396d, 
+0x396f, 0x39ce, 0x39d1, 0x39de, 0x39e0, 0x3a72, 0x3a74, 0x3b4d, 
+0x3b4f, 0x3c6d, 0x3c6f, 0x3cdf, 0x3ce1, 0x4055, 0x4057, 0x415e, 
+0x4160, 0x4336, 0x4338, 0x43ab, 0x43ad, 0x43b0, 0x43b2, 0x43dc, 
+0x43de, 0x44d5, 0x44d7, 0x464b, 0x464d, 0x4660, 0x4662, 0x4722, 
+0x4724, 0x4728, 0x472a, 0x477b, 0x477d, 0x478c, 0x478e, 0x4946, 
+0x4948, 0x4979, 0x497b, 0x497c, 0x497e, 0x4981, 0x4984, 0x4984, 
+0x4987, 0x499a, 0x499c, 0x499e, 0x49a0, 0x49b5, 0x49b8, 0x4c76, 
+0x4c78, 0x4c9e, 0x4ca4, 0x4d12, 0x4d1a, 0x4dad, 0x4daf, 0x4dff, 
+0x9fa6, 0xd7ff, 0xe76c, 0xe76c, 0xe7c8, 0xe7c8, 0xe7e7, 0xe7f3, 
+0xe815, 0xe815, 0xe819, 0xe81d, 0xe81f, 0xe825, 0xe827, 0xe82a, 
+0xe82d, 0xe830, 0xe833, 0xe83a, 0xe83c, 0xe842, 0xe844, 0xe853, 
+0xe856, 0xe863, 0xe865, 0xf92b, 0xf92d, 0xf978, 0xf97a, 0xf994, 
+0xf996, 0xf9e6, 0xf9e8, 0xf9f0, 0xf9f2, 0xfa0b, 0xfa10, 0xfa10, 
+0xfa12, 0xfa12, 0xfa15, 0xfa17, 0xfa19, 0xfa1e, 0xfa22, 0xfa22, 
+0xfa25, 0xfa26, 0xfa2a, 0xfe2f, 0xfe32, 0xfe32, 0xfe45, 0xfe48, 
+0xfe53, 0xfe53, 0xfe58, 0xfe58, 0xfe67, 0xfe67, 0xfe6c, 0xff00, 
+0xff5f, 0xffdf, 0xffe6, 0xffff, 
+};
+
+static const unsigned short mbfl_gb_uni_ofst[] = {
+   128,    129,    131,    133,    134,    135,    137,    140, 
+   142,    144,    145,    147,    148,    149,    150,    151, 
+   152,    153,    154,    155,    156,    157,    158,    159, 
+   160,    161,    162,    163,    164,    165,    166,    167, 
+   168,    171,    172,    189,    196,    213,    220,    221, 
+   285,    286,    287,    291,    293,    295,    297,    298, 
+   300,    301,    302,    303,    304,    305,    306,    307, 
+   308,    320,    330,    334,    338,    339,    340,    341, 
+   342,    343,    347,    348,    349,    354,    355,    359, 
+   360,    361,    362,    363,    365,    369,    371,    372, 
+   373,    374,    375,    376,    386,    426,    502,    538, 
+   553,    556,    558,    560,    562,    564,    565,    567, 
+   571,    573,    574,    575,    576,    577,    578,    579, 
+   581,    582,    583,    584,    585,    586,    588,    589, 
+   590,    602,    606,    625,    627,    636,    637,    720, 
+   724,    810,    813,    850,    860,    861,    862,    864, 
+   867,    868,    869,    870,    872,    873,    874,    875, 
+   876,    877,    878,    879,    880,    882,    883,    884, 
+   885,    886,    887,    888,    889,    890,    891,    892, 
+   893,    894,    895,    896,    897,    898,    899,    900, 
+   901,    902,    903,    905,    907,    908,    909,    911, 
+   912,    917,    924,    925,  21827,  25775,  25866,  25896, 
+ 25929,  25932,  25933,  25934,  25936,  25938,  25939,  25940, 
+ 25942,  25943,  25944,  25945,  25946,  25947,  25948,  25952, 
+ 25953,  25955,  25956,  25959,  25961,  25964,  25966,  25984, 
+ 25994,  25998,  26012,  26016,  26110,  26116, 
+};
+
+static const int mbfl_gb_uni_max = sizeof(mbfl_gb_uni_ofst)/sizeof(unsigned short);
+
+
+#endif /* UNICODE_TABLE_GB18030_H */
index 05f11cdf22215ef4a148f3b42fc50a057fd41bbc..07c6296eea8091c4f676b70827cefbacfe091bdd 100644 (file)
@@ -81,6 +81,7 @@
 #define MBFL_WCSPLANE_KOI8U            0x70fc0000
 #define MBFL_WCSPLANE_CP1254           0x70fd0000              /*  00h - FFh */
 #define MBFL_WCSPLANE_CP850            0x70fe0000              /*  00h - FFh */
+#define MBFL_WCSPLANE_GB18030          0x70ff0000              /* a1a1h-e3329a35h  */
 #define MBFL_WCSGROUP_MASK                0xffffff
 #define MBFL_WCSGROUP_UCS4MAX          0x70000000
 #define MBFL_WCSGROUP_WCHARMAX         0x78000000
index 644ab3421fd9d3fac5901b0c28560c1ccba10ec6..e3ac774fd053140a50854b5fd691ad461fc384fe 100644 (file)
@@ -59,6 +59,7 @@
 #include "filters/mbfilter_iso2022_jp_ms.h"
 #include "filters/mbfilter_euc_jp.h"
 #include "filters/mbfilter_euc_jp_win.h"
+#include "filters/mbfilter_gb18030.h"
 #include "filters/mbfilter_ascii.h"
 #include "filters/mbfilter_koi8r.h"
 #include "filters/mbfilter_koi8u.h"
@@ -156,6 +157,8 @@ const struct mbfl_convert_vtbl *mbfl_convert_filter_list[] = {
        &vtbl_wchar_euccn,
        &vtbl_cp936_wchar,
        &vtbl_wchar_cp936,
+       &vtbl_gb18030_wchar,
+       &vtbl_wchar_gb18030,
        &vtbl_hz_wchar,
        &vtbl_wchar_hz,
        &vtbl_euctw_wchar,
index b4bfa2b4d0a6fbb30c2900d0cd2c9cd78756af47..85c4339f283a4b6cd43e66e25490e5e0f211665d 100644 (file)
@@ -65,6 +65,7 @@
 #include "filters/mbfilter_iso2022_jp_ms.h"
 #include "filters/mbfilter_euc_jp.h"
 #include "filters/mbfilter_euc_jp_win.h"
+#include "filters/mbfilter_gb18030.h"
 #include "filters/mbfilter_ascii.h"
 #include "filters/mbfilter_koi8r.h"
 #include "filters/mbfilter_koi8u.h"
@@ -176,6 +177,7 @@ static const mbfl_encoding *mbfl_encoding_ptr_list[] = {
        &mbfl_encoding_jis,
        &mbfl_encoding_2022jp,
        &mbfl_encoding_2022jpms,
+       &mbfl_encoding_gb18030,
        &mbfl_encoding_cp1252,
        &mbfl_encoding_cp1254,
        &mbfl_encoding_8859_1,
index bd094739e8368fe14757c8308e96ec837542af58..1ac05757ce7b9d2faa18e79f9ca937ab73b1e8a4 100644 (file)
@@ -86,6 +86,7 @@ enum mbfl_no_encoding {
        mbfl_no_encoding_jis,
        mbfl_no_encoding_2022jp,
        mbfl_no_encoding_2022jpms,
+       mbfl_no_encoding_gb18030,
        mbfl_no_encoding_cp1252,
        mbfl_no_encoding_cp1254,
        mbfl_no_encoding_8859_1,
index 0cfdcdba90da67ac6cb5690c8a80f5d03b89702f..fdffc7047166201daba3852d1879e1054ab7d610 100644 (file)
@@ -68,6 +68,7 @@
 #include "filters/mbfilter_cp1254.h"
 #include "filters/mbfilter_cp51932.h"
 #include "filters/mbfilter_cp5022x.h"
+#include "filters/mbfilter_gb18030.h"
 #include "filters/mbfilter_iso8859_1.h"
 #include "filters/mbfilter_iso8859_2.h"
 #include "filters/mbfilter_iso8859_3.h"
@@ -158,6 +159,7 @@ static const struct mbfl_identify_vtbl *mbfl_identify_filter_list[] = {
        &vtbl_identify_cp50220,
        &vtbl_identify_cp50221,
        &vtbl_identify_cp50222,
+       &vtbl_identify_gb18030,
        &vtbl_identify_false,
        NULL
 };