]> granicus.if.org Git - php/commitdiff
MFH: reduced footprint for sjis-mac
authorRui Hirokawa <hirokawa@php.net>
Sun, 28 Aug 2011 04:32:33 +0000 (04:32 +0000)
committerRui Hirokawa <hirokawa@php.net>
Sun, 28 Aug 2011 04:32:33 +0000 (04:32 +0000)
ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c
ext/mbstring/libmbfl/filters/sjis_mac2uni.h

index 742425720b4e7c0565c9fe5cd6dba9c73617aac3..2f84edff2199543964cf182a801a763d0a1abdc8 100644 (file)
@@ -37,6 +37,8 @@
 #include "unicode_table_cp932_ext.h"
 #include "unicode_table_jis.h"
 
+#include "sjis_mac2uni.h"
+
 extern int mbfl_filt_ident_sjis(int c, mbfl_identify_filter *filter);
 extern const unsigned char mblen_table_sjis[];
 
@@ -123,134 +125,6 @@ const struct mbfl_convert_vtbl vtbl_wchar_sjis_mac = {
                        }                                               \
                } while (0)
 
-#include "sjis_mac2uni.h"
-
-static const int code_tbl[][3] = {
-       {0x02f0, 0x0303, 0x2460},
-       {0x030e, 0x0321, 0x2474},
-       {0x032c, 0x0334, 0x2776},
-       {0x0341, 0x0349, 0x2488},
-       {0x034e, 0x0359, 0x2160},
-       {0x0362, 0x036d, 0x2170},
-       {0x038a, 0x03a3, 0x249c},
-};
-
-static const int code_ofst_tbl[] [2]= {
-       {0x03ac, 0x03c9},
-       {0x0406, 0x0420},
-       {0x0432, 0x0441},
-       {0x0468, 0x0480},
-       {0x04b8, 0x04e8},
-       {0x050c, 0x0551},
-       {0x1ed9, 0x1f18},
-       {0x1ff2, 0x20a5},
-};
-
-static const int *code_map[] = {
-       sjis_mac2wchar1, sjis_mac2wchar2, sjis_mac2wchar3, sjis_mac2wchar4,
-       sjis_mac2wchar5, sjis_mac2wchar6, sjis_mac2wchar7, sjis_mac2wchar8};
-
-static const int code_tbl_m[][6] = {
-       {0x0340, 0xf860, 0x0030, 0x002e, 0x0000, 0x0000},
-       {0x03c9, 0xf860, 0x0054, 0x0042, 0x0000, 0x0000},
-       {0x035c, 0xf860, 0x0058, 0x0056, 0x0000, 0x0000},
-       {0x0370, 0xf860, 0x0078, 0x0076, 0x0000, 0x0000},
-       {0x0439, 0xf860, 0x2193, 0x2191, 0x0000, 0x0000},
-       {0x0409, 0xf861, 0x0046, 0x0041, 0x0058, 0x0000},
-       {0x035b, 0xf861, 0x0058, 0x0049, 0x0056, 0x0000},
-       {0x036f, 0xf861, 0x0078, 0x0069, 0x0076, 0x0000},
-       {0x035a, 0xf862, 0x0058, 0x0049, 0x0049, 0x0049},
-       {0x036e, 0xf862, 0x0078, 0x0069, 0x0069, 0x0069},
-       {0x0522, 0xf862, 0x6709, 0x9650, 0x4f1a, 0x793e},
-       {0x0523, 0xf862, 0x8ca1, 0x56e3, 0x6cd5, 0x4eba},
-};
-
-static const int s_form_tbl[] = {
-       0x2010,0x2016,0x2026,
-       0x3001,0x3002,0x301c,0x3041,0x3043,0x3045,0x3047,0x3049,
-       0x3063,0x3083,0x3085,0x3087,0x308e,0x30a1,0x30a3,0x30a5,
-       0x30a7,0x30a9,0x30c3,0x30e3,0x30e5,0x30e7,0x30ee,0x30f5,
-       0x30f6,0x30fc,0xff1d,0xff3b,0xff3d,0xff5c,0xffe3, // vertical f87e (34)
-       0x2026,0xff47,0xff4d, // halfwidth f87f (3)
-       0x5927,0x5c0f,0x63a7, // enclosing circle 20dd (3)
-       0x21e6,0x21e7,0x21e8,0x21e9, // black arrow f87a (4)
-};
-
-static const int s_form_sjis_tbl[] = {
-       0xeb5d,0xeb61,0xeb63,
-       0xeb41,0xeb42,0xeb60,0xec9f,0xeca1,0xeca3,0xeca5,0xeca7,
-       0xecc1,0xece1,0xece3,0xece5,0xecec,0xed40,0xed42,0xed44,
-       0xed46,0xed48,0xed62,0xed83,0xed85,0xed87,0xed8e,0xed95,
-       0xed96,0xeb5b,0xeb81,0xeb6d,0xeb6e,0xeb62,0xeb50, // vertical
-       0x00ff,0x864b,0x8645, // halfwidth
-       0x8791,0x8792,0x879d, // enclosing circle
-       0x86d4,0x86d5,0x86d3,0x86d6, // black arrow
-};
-
-static const int s_form_sjis_fallback_tbl[] = {
-       0x815d,0x8161,0x8163,
-       0x8141,0x8142,0x8160,0x829f,0x82a1,0x82a3,0x82a5,0x82a7,
-       0x82c1,0x82e1,0x82e3,0x82e5,0x82ec,0x8340,0x8342,0x8344,
-       0x8346,0x8348,0x8362,0x8383,0x8385,0x8387,0x838e,0x8395,
-       0x8396,0x815b,0x8181,0x816d,0x816e,0x8162,0x8150, // vertical
-       0x815d,0x8287,0x828d, // halfwidth
-       0x91e5,0x8fac,0x8d54, // enclosing circle
-       0x86d0,0x86d1,0x86cf,0x86d2, // arrow
-};
-
-static const int wchar2sjis_mac_r_tbl[][3] = {
-       {0x2160, 0x216b, 0x034e},
-       {0x2170, 0x217b, 0x0362},
-       {0x2460, 0x2473, 0x02f0},
-       {0x2474, 0x2487, 0x030e},
-       {0x2488, 0x2490, 0x0341},
-       {0x249c, 0x24b5, 0x038a},
-       {0x2776, 0x277e, 0x032c},
-       {0x30f7, 0x30fa, 0x054e},
-       {0x32a4, 0x32a9, 0x04ba},
-};
-
-static const unsigned short wchar2sjis_mac_r_map[][2] = {
-       {0x2660, 0x2667},
-       {0x322a, 0x3243},
-       {0x3296, 0x329e},
-       {0x3300, 0x33d4},
-       {0xfe30, 0xfe44},
-};
-
-static const int *wchar2sjis_mac_code_map[] = {
-       wchar2sjis_mac4, wchar2sjis_mac7, wchar2sjis_mac8, wchar2sjis_mac9, wchar2sjis_mac10};
-
-static const int wchar2sjis_mac_wchar_tbl[][2] = {
-       {0x2109, 0x03c2},
-       {0x2110, 0x21ef5},
-       {0x2113, 0x03bc},
-       {0x2116, 0x0406},
-       {0x2121, 0x0408},
-       {0x21c4, 0x0437},
-       {0x21c5, 0x0438},
-       {0x21c6, 0x0436},
-       {0x21e6, 0x043b},
-       {0x21e7, 0x043c},
-       {0x21e8, 0x043a},
-       {0x21e9, 0x043d},
-       {0x221f, 0x0525},
-       {0x222e, 0x0524},
-       {0x22bf, 0x0526},
-       {0x260e, 0x041f},
-       {0x261c, 0x0433},
-       {0x261d, 0x0434},
-       {0x261e, 0x0432},
-       {0x261f, 0x0435},
-       {0x3004, 0x0420},
-       {0x301d, 0x0538},
-       {0x301f, 0x0539},
-       {0x3020, 0x041e},
-       {0x3094, 0x054c},
-};
-
-
-
 /*
  * SJIS-mac => wchar
  */
@@ -328,7 +202,7 @@ mbfl_filt_conv_sjis_mac_wchar(int c, mbfl_convert_filter *filter)
 
                        if (w == 0) {
 
-                               for (i=0; i<12; i++) {
+                               for (i=0; i<code_tbl_m_len; i++) {
                                        if (s == code_tbl_m[i][0]) {
                                                if (code_tbl_m[i][1] == 0xf860) {
                                                        n = 4;
@@ -350,21 +224,22 @@ mbfl_filt_conv_sjis_mac_wchar(int c, mbfl_convert_filter *filter)
                                for (i=0; i<8; i++) {
                                        if (s >= code_ofst_tbl[i][0] && s <= code_ofst_tbl[i][1]) {
                                                w = code_map[i][s - code_ofst_tbl[i][0]];
-                                               if (w >= 0x10000) {
-                                                       CK((*filter->output_function)(w & 0xffff, filter->data));
-                                                       if (w & 0x10000) {
-                                                               w = 0xf87a;
-                                                       } else if (w & 0x20000) {
-                                                               w = 0xf87e;
-                                                       } else if (w & 0x40000) {
-                                                               w = 0xf87f;
-                                                       } else if (w & 0x80000) {
-                                                               w = 0x20dd;
-                                                       } else {
-                                                               w = 0;
-                                                       }
+                                               s2 = 0;
+                                               if (s >= 0x043e && s <= 0x0441) {
+                                                       s2 = 0xf87a;
+                                               } else if (s == 0x03b1 || s == 0x03b7) {
+                                                       s2 = 0xf87f;
+                                               } else if (s == 0x04b8 || s == 0x04b9 || s == 0x04c4) {
+                                                       s2 = 0x20dd;
+                                               } else if (s == 0x1ed9 || s == 0x1eda || s == 0x1ee8 || s == 0x1ef3 ||
+                                                                  (s >= 0x1ef5 && s <= 0x1efb) || s == 0x1f05 || s == 0x1f06 ||
+                                                                  s == 0x1f18 || (s >= 0x1ff2 && s <= 0x20a5)) {
+                                                       s2 = 0xf87e;
+                                               }
+                                               if (s2 > 0) {
+                                                       CK((*filter->output_function)(w, filter->data));
+                                                       w = s2;
                                                }
-                                               
                                                break;
                                        }
                                }
@@ -471,7 +346,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
                }
 
                if (s2 > 0) {
-                       for (i=0;i<sizeof(s_form_tbl)/sizeof(int);i++) {
+                       for (i=0;i<s_form_tbl_len;i++) {
                                if (c1 == s_form_tbl[i]) {
                                        s1 = s_form_sjis_fallback_tbl[i];
                                        break;
@@ -521,7 +396,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
                }
                
                if (c >= 0x2000) {
-                       for (i=0;i<sizeof(s_form_tbl)/sizeof(int);i++) {
+                       for (i=0;i<s_form_tbl_len;i++) {
                                if (c == s_form_tbl[i]) {
                                        filter->status = 1;
                                        filter->cache = c;
@@ -556,7 +431,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
                }
                
                if (s1 <= 0) {
-                       for (i=0; i<sizeof(wchar2sjis_mac_r_tbl)/(3*sizeof(int));i++) {
+                       for (i=0; i<wchar2sjis_mac_r_tbl_len; i++) {
                                if (c >= wchar2sjis_mac_r_tbl[i][0] && c <= wchar2sjis_mac_r_tbl[i][1]) {
                                        s1 = c - wchar2sjis_mac_r_tbl[i][0] + wchar2sjis_mac_r_tbl[i][2];
                                        break;
@@ -564,7 +439,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
                        }
 
                        if (s1 <= 0) {
-                               for (i=0; i<sizeof(wchar2sjis_mac_r_map)/(2*sizeof(unsigned short));i++) {
+                               for (i=0; i<wchar2sjis_mac_r_map_len; i++) {
                                        if (c >= wchar2sjis_mac_r_map[i][0] && c <= wchar2sjis_mac_r_map[i][1]) {
                                                s1 = wchar2sjis_mac_code_map[i][c-wchar2sjis_mac_r_map[i][0]]; 
                                                break;
@@ -573,7 +448,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
                        }
 
                        if (s1 <= 0) {
-                               for (i=0; i<sizeof(wchar2sjis_mac_wchar_tbl)/(2*sizeof(int));i++) {
+                               for (i=0; i<wchar2sjis_mac_wchar_tbl_len ; i++) {
                                        if ( c == wchar2sjis_mac_wchar_tbl[i][0]) {
                                                s1 = wchar2sjis_mac_wchar_tbl[i][1] & 0xffff;
                                                break;
@@ -802,7 +677,7 @@ mbfl_filt_conv_sjis_mac_flush(mbfl_convert_filter *filter)
        int i, c1, s1 = 0;
        if (filter->status == 1 && filter->cache > 0) {
                c1 = filter->cache;
-               for (i=0;i<sizeof(s_form_tbl)/sizeof(int);i++) {
+               for (i=0;i<s_form_tbl_len;i++) {
                        if (c1 == s_form_tbl[i]) {
                                s1 = s_form_sjis_fallback_tbl[i];
                                break;
index cbfdf311dad2a7f993a23427a190e2cb57d0e73e..1bd77c91a33bff2d7d2e6a244b9d50ed8922bbab 100644 (file)
-const int sjis_mac2wchar1[] = { // 0x03ac - 0x03c9
-0x0339c,       0x0339f,        0x0339d,        0x033a0,        
-0x033a4,       0x4ff4d,        0x033a1,        0x033a5,        
-0x0339e,       0x033a2,        0x0338e,        0x4ff47,        
-0x0338f,       0x033c4,        0x03396,        0x03397,        
-0x02113,       0x03398,        0x033b3,        0x033b2,        
-0x033b1,       0x033b0,        0x02109,        0x033d4,        
-0x033cb,       0x03390,        0x03385,        0x03386,        
-0x03387,       0xff860,        };
-const int sjis_mac2wchar2[] = { // 0x0406 - 0x0420
-0x02116,       0x033cd,        
-0x02121,       0xff861,        0x02664,        0x02667,        
-0x02661,       0x02662,        0x02660,        0x02663,        
-0x02665,       0x02666,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x03020,        0x0260e,        
-0x03004,       };
-const int sjis_mac2wchar3[] = { // 0x0432 - 0x0441
-0x0261e,       0x0261c,        
-0x0261d,       0x0261f,        0x021c6,        0x021c4,        
-0x021c5,       0xff860,        0x021e8,        0x021e6,        
-0x021e7,       0x021e9,        0x121e8,        0x121e6,        
-0x121e7,       0x121e9,        };
-const int sjis_mac2wchar4[] = { // 0x0468 - 0x0480
-0x03230,       0x0322a,        0x0322b,        0x0322c,        
-0x0322d,       0x0322e,        0x0322f,        0x03240,        
-0x03237,       0x03242,        0x03243,        0x03239,        
-0x0323a,       0x03231,        0x0323e,        0x03234,        
-0x03232,       0x0323b,        0x03236,        0x03233,        
-0x03235,       0x0323c,        0x0323d,        0x0323f,        
-0x03238,       };
-const int sjis_mac2wchar5[] = { // 0x04b8 - 0x04e8
-0x85927,       0x85c0f,        0x032a4,        0x032a5,        
-0x032a6,       0x032a7,        0x032a8,        0x032a9,        
-0x03296,       0x0329d,        0x03298,        0x0329e,        
-0x863a7,       0x03299,        0x03349,        0x03322,        
-0x0334d,       0x03314,        0x03316,        0x03305,        
-0x03333,       0x0334e,        0x03303,        0x03336,        
-0x03318,       0x03315,        0x03327,        0x03351,        
-0x0334a,       0x03339,        0x03357,        0x0330d,        
-0x03342,       0x03323,        0x03326,        0x0333b,        
-0x0332b,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x03300,       0x0331e,        0x0332a,        0x03331,        
-0x03347,       };
-const int sjis_mac2wchar6[] = { // 0x050c - 0x0551
-0x0337e,       0x0337d,        0x0337c,        0x0337b,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x0337f,        0xff862,        0xff862,        
-0x0222e,       0x0221f,        0x022bf,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x0301d,       0x0301f,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x03094,       0x00000,        0x030f7,        0x030f8,        
-0x030f9,       0x030fa,        };
-const int sjis_mac2wchar7[] = { // 0x1ed9 - 0x1f18
-0x23001,       0x23002,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x2ffe3,       0x0fe33,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x230fc,        
-0x0fe31,       0x22010,        0x00000,        0x00000,        
-0x2301c,       0x22016,        0x2ff5c,        0x22026,        
-0x0fe30,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x0fe35,        0x0fe36,        0x0fe39,        
-0x0fe3a,       0x2ff3b,        0x2ff3d,        0x0fe37,        
-0x0fe38,       0x0fe3f,        0x0fe40,        0x0fe3d,        
-0x0fe3e,       0x0fe41,        0x0fe42,        0x0fe43,        
-0x0fe44,       0x0fe3b,        0x0fe3c,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x2ff1d,       };
-const int sjis_mac2wchar8[] = { // 0x1ff2 - 0x20a5
-0x23041,       0x00000,        
-0x23043,       0x00000,        0x23045,        0x00000,        
-0x23047,       0x00000,        0x23049,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x23063,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x23083,       0x00000,        0x23085,        0x00000,        
-0x23087,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x2308e,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x230a1,       0x00000,        0x230a3,        0x00000,        
-0x230a5,       0x00000,        0x230a7,        0x00000,        
-0x230a9,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x230c3,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x230e3,        0x00000,        
-0x230e5,       0x00000,        0x230e7,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x00000,       0x230ee,        0x00000,        0x00000,        
-0x00000,       0x00000,        0x00000,        0x00000,        
-0x230f5,       0x230f6,        };
-
-const int wchar2sjis_mac4[] = { // 0x2660 - 0x2667
+
+
+static const unsigned short sjis_mac2wchar1[] = { // 0x03ac - 0x03c9
+0x339c,        0x339f, 0x339d, 0x33a0, 
+0x33a4,        0xff4d, 0x33a1, 0x33a5, 
+0x339e,        0x33a2, 0x338e, 0xff47, 
+0x338f,        0x33c4, 0x3396, 0x3397, 
+0x2113,        0x3398, 0x33b3, 0x33b2, 
+0x33b1,        0x33b0, 0x2109, 0x33d4, 
+0x33cb,        0x3390, 0x3385, 0x3386, 
+0x3387,        0xf860, };
+static const unsigned short sjis_mac2wchar2[] = { // 0x0406 - 0x0420
+0x2116,        0x33cd, 
+0x2121,        0xf861, 0x2664, 0x2667, 
+0x2661,        0x2662, 0x2660, 0x2663, 
+0x2665,        0x2666, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x3020, 0x260e, 
+0x3004,        };
+static const unsigned short sjis_mac2wchar3[] = { // 0x0432 - 0x0441
+0x261e,        0x261c, 
+0x261d,        0x261f, 0x21c6, 0x21c4, 
+0x21c5,        0xf860, 0x21e8, 0x21e6, 
+0x21e7,        0x21e9, 0x21e8, 0x21e6, 
+0x21e7,        0x21e9, };
+static const unsigned short sjis_mac2wchar4[] = { // 0x0468 - 0x0480
+0x3230,        0x322a, 0x322b, 0x322c, 
+0x322d,        0x322e, 0x322f, 0x3240, 
+0x3237,        0x3242, 0x3243, 0x3239, 
+0x323a,        0x3231, 0x323e, 0x3234, 
+0x3232,        0x323b, 0x3236, 0x3233, 
+0x3235,        0x323c, 0x323d, 0x323f, 
+0x3238,        };
+static const unsigned short sjis_mac2wchar5[] = { // 0x04b8 - 0x04e8
+0x5927,        0x5c0f, 0x32a4, 0x32a5, 
+0x32a6,        0x32a7, 0x32a8, 0x32a9, 
+0x3296,        0x329d, 0x3298, 0x329e, 
+0x63a7,        0x3299, 0x3349, 0x3322, 
+0x334d,        0x3314, 0x3316, 0x3305, 
+0x3333,        0x334e, 0x3303, 0x3336, 
+0x3318,        0x3315, 0x3327, 0x3351, 
+0x334a,        0x3339, 0x3357, 0x330d, 
+0x3342,        0x3323, 0x3326, 0x333b, 
+0x332b,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x3300,        0x331e, 0x332a, 0x3331, 
+0x3347,        };
+static const unsigned short sjis_mac2wchar6[] = { // 0x050c - 0x0551
+0x337e,        0x337d, 0x337c, 0x337b, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x337f, 0xf862, 0xf862, 
+0x222e,        0x221f, 0x22bf, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x301d,        0x301f, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x3094,        0x0000, 0x30f7, 0x30f8, 
+0x30f9,        0x30fa, };
+static const unsigned short sjis_mac2wchar7[] = { // 0x1ed9 - 0x1f18
+0x3001,        0x3002, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0xffe3,        0xfe33, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x30fc, 
+0xfe31,        0x2010, 0x0000, 0x0000, 
+0x301c,        0x2016, 0xff5c, 0x2026, 
+0xfe30,        0x0000, 0x0000, 0x0000, 
+0x0000,        0xfe35, 0xfe36, 0xfe39, 
+0xfe3a,        0xff3b, 0xff3d, 0xfe37, 
+0xfe38,        0xfe3f, 0xfe40, 0xfe3d, 
+0xfe3e,        0xfe41, 0xfe42, 0xfe43, 
+0xfe44,        0xfe3b, 0xfe3c, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0xff1d,        };
+static const unsigned short sjis_mac2wchar8[] = { // 0x1ff2 - 0x20a5
+0x3041,        0x0000, 
+0x3043,        0x0000, 0x3045, 0x0000, 
+0x3047,        0x0000, 0x3049, 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, 
+0x3063,        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, 
+0x3083,        0x0000, 0x3085, 0x0000, 
+0x3087,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x308e, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x30a1,        0x0000, 0x30a3, 0x0000, 
+0x30a5,        0x0000, 0x30a7, 0x0000, 
+0x30a9,        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, 0x30c3, 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, 0x30e3, 0x0000, 
+0x30e5,        0x0000, 0x30e7, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x0000,        0x30ee, 0x0000, 0x0000, 
+0x0000,        0x0000, 0x0000, 0x0000, 
+0x30f5,        0x30f6, };
+
+static const unsigned short wchar2sjis_mac4[] = { // 0x2660 - 0x2667
 0x040e,        0x040c, 0x040d, 0x040f, 
 0x040a,        0x0410, 0x0411, 0x040b, 
 };
 
-const int wchar2sjis_mac7[] = { // 0x322a - 0x3243
+static const unsigned short wchar2sjis_mac7[] = { // 0x322a - 0x3243
 0x0469, 0x046a, 
 0x046b, 0x046c, 0x046d, 0x046e, 
 0x0468, 0x0475, 0x0478, 0x047b, 
@@ -144,12 +146,12 @@ const int wchar2sjis_mac7[] = { // 0x322a - 0x3243
 0x046f, 0x0000, 0x0471, 0x0472, 
 };
 
-const int wchar2sjis_mac8[] = { // 0x3296 - 0x329e
+static const unsigned short wchar2sjis_mac8[] = { // 0x3296 - 0x329e
 0x04c0, 0x0000, 
 0x04c2, 0x04c5, 0x0000, 0x0000, 
 0x0000, 0x04c1, 0x04c3, };
 
-const int wchar2sjis_mac9[] = { // 0x3300 - 0x33d4
+static const unsigned short wchar2sjis_mac9[] = { // 0x3300 - 0x33d4
 0x04e4,        0x0000, 0x0000, 0x04ce, 
 0x0000,        0x04cb, 0x0000, 0x0000, 
 0x0000,        0x0000, 0x0000, 0x0000, 
@@ -205,10 +207,143 @@ const int wchar2sjis_mac9[] = { // 0x3300 - 0x33d4
 0x0000,        0x0000, 0x0000, 0x0000, 
 0x03c3,        };
 
-const int wchar2sjis_mac10[] = { // 0xfe30 - 0xfe44
+static const unsigned short wchar2sjis_mac10[] = { // 0xfe30 - 0xfe44
 0x1efc,        0x1ef4, 0x0000, 0x1ee9, 
 0x0000,        0x1f01, 0x1f02, 0x1f07, 
 0x1f08,        0x1f03, 0x1f04, 0x1f11, 
 0x1f12,        0x1f0b, 0x1f0c, 0x1f09, 
 0x1f0a,        0x1f0d, 0x1f0e, 0x1f0f, 
 0x1f10,        };
+
+static const unsigned short code_tbl[][3] = {
+       {0x02f0, 0x0303, 0x2460},
+       {0x030e, 0x0321, 0x2474},
+       {0x032c, 0x0334, 0x2776},
+       {0x0341, 0x0349, 0x2488},
+       {0x034e, 0x0359, 0x2160},
+       {0x0362, 0x036d, 0x2170},
+       {0x038a, 0x03a3, 0x249c},
+};
+
+static const unsigned short code_ofst_tbl[] [2]= {
+       {0x03ac, 0x03c9},
+       {0x0406, 0x0420},
+       {0x0432, 0x0441},
+       {0x0468, 0x0480},
+       {0x04b8, 0x04e8},
+       {0x050c, 0x0551},
+       {0x1ed9, 0x1f18},
+       {0x1ff2, 0x20a5},
+};
+
+static const unsigned short *code_map[] = {
+       sjis_mac2wchar1, sjis_mac2wchar2, sjis_mac2wchar3, sjis_mac2wchar4,
+       sjis_mac2wchar5, sjis_mac2wchar6, sjis_mac2wchar7, sjis_mac2wchar8};
+
+static const unsigned short code_tbl_m[][6] = {
+       {0x0340, 0xf860, 0x0030, 0x002e, 0x0000, 0x0000},
+       {0x03c9, 0xf860, 0x0054, 0x0042, 0x0000, 0x0000},
+       {0x035c, 0xf860, 0x0058, 0x0056, 0x0000, 0x0000},
+       {0x0370, 0xf860, 0x0078, 0x0076, 0x0000, 0x0000},
+       {0x0439, 0xf860, 0x2193, 0x2191, 0x0000, 0x0000},
+       {0x0409, 0xf861, 0x0046, 0x0041, 0x0058, 0x0000},
+       {0x035b, 0xf861, 0x0058, 0x0049, 0x0056, 0x0000},
+       {0x036f, 0xf861, 0x0078, 0x0069, 0x0076, 0x0000},
+       {0x035a, 0xf862, 0x0058, 0x0049, 0x0049, 0x0049},
+       {0x036e, 0xf862, 0x0078, 0x0069, 0x0069, 0x0069},
+       {0x0522, 0xf862, 0x6709, 0x9650, 0x4f1a, 0x793e},
+       {0x0523, 0xf862, 0x8ca1, 0x56e3, 0x6cd5, 0x4eba},
+};
+
+static  int code_tbl_m_len = sizeof(code_tbl_m)/(sizeof(unsigned short)*6);
+
+static const unsigned short s_form_tbl[] = {
+       0x2010,0x2016,0x2026,
+       0x3001,0x3002,0x301c,0x3041,0x3043,0x3045,0x3047,0x3049,
+       0x3063,0x3083,0x3085,0x3087,0x308e,0x30a1,0x30a3,0x30a5,
+       0x30a7,0x30a9,0x30c3,0x30e3,0x30e5,0x30e7,0x30ee,0x30f5,
+       0x30f6,0x30fc,0xff1d,0xff3b,0xff3d,0xff5c,0xffe3, // vertical f87e (34)
+       0x2026,0xff47,0xff4d, // halfwidth f87f (3)
+       0x5927,0x5c0f,0x63a7, // enclosing circle 20dd (3)
+       0x21e6,0x21e7,0x21e8,0x21e9, // black arrow f87a (4)
+};
+
+static int s_form_tbl_len = sizeof(s_form_tbl)/sizeof(unsigned short);
+
+static const unsigned short s_form_sjis_tbl[] = {
+       0xeb5d,0xeb61,0xeb63,
+       0xeb41,0xeb42,0xeb60,0xec9f,0xeca1,0xeca3,0xeca5,0xeca7,
+       0xecc1,0xece1,0xece3,0xece5,0xecec,0xed40,0xed42,0xed44,
+       0xed46,0xed48,0xed62,0xed83,0xed85,0xed87,0xed8e,0xed95,
+       0xed96,0xeb5b,0xeb81,0xeb6d,0xeb6e,0xeb62,0xeb50, // vertical
+       0x00ff,0x864b,0x8645, // halfwidth
+       0x8791,0x8792,0x879d, // enclosing circle
+       0x86d4,0x86d5,0x86d3,0x86d6, // black arrow
+};
+
+static const unsigned short s_form_sjis_fallback_tbl[] = {
+       0x815d,0x8161,0x8163,
+       0x8141,0x8142,0x8160,0x829f,0x82a1,0x82a3,0x82a5,0x82a7,
+       0x82c1,0x82e1,0x82e3,0x82e5,0x82ec,0x8340,0x8342,0x8344,
+       0x8346,0x8348,0x8362,0x8383,0x8385,0x8387,0x838e,0x8395,
+       0x8396,0x815b,0x8181,0x816d,0x816e,0x8162,0x8150, // vertical
+       0x815d,0x8287,0x828d, // halfwidth
+       0x91e5,0x8fac,0x8d54, // enclosing circle
+       0x86d0,0x86d1,0x86cf,0x86d2, // arrow
+};
+
+static const unsigned short wchar2sjis_mac_r_tbl[][3] = {
+       {0x2160, 0x216b, 0x034e},
+       {0x2170, 0x217b, 0x0362},
+       {0x2460, 0x2473, 0x02f0},
+       {0x2474, 0x2487, 0x030e},
+       {0x2488, 0x2490, 0x0341},
+       {0x249c, 0x24b5, 0x038a},
+       {0x2776, 0x277e, 0x032c},
+       {0x30f7, 0x30fa, 0x054e},
+       {0x32a4, 0x32a9, 0x04ba},
+};
+
+static int wchar2sjis_mac_r_tbl_len = sizeof(wchar2sjis_mac_r_tbl)/(3*sizeof(unsigned short));
+
+static const unsigned short wchar2sjis_mac_r_map[][2] = {
+       {0x2660, 0x2667},
+       {0x322a, 0x3243},
+       {0x3296, 0x329e},
+       {0x3300, 0x33d4},
+       {0xfe30, 0xfe44},
+};
+
+static int wchar2sjis_mac_r_map_len = sizeof(wchar2sjis_mac_r_map)/(2*sizeof(unsigned short));
+
+static const unsigned short *wchar2sjis_mac_code_map[] = {
+       wchar2sjis_mac4, wchar2sjis_mac7, wchar2sjis_mac8, wchar2sjis_mac9, wchar2sjis_mac10};
+
+static const unsigned short wchar2sjis_mac_wchar_tbl[][2] = {
+       {0x2109, 0x03c2},
+       {0x2113, 0x03bc},
+       {0x2116, 0x0406},
+       {0x2121, 0x0408},
+       {0x21c4, 0x0437},
+       {0x21c5, 0x0438},
+       {0x21c6, 0x0436},
+       {0x21e6, 0x043b},
+       {0x21e7, 0x043c},
+       {0x21e8, 0x043a},
+       {0x21e9, 0x043d},
+       {0x221f, 0x0525},
+       {0x222e, 0x0524},
+       {0x22bf, 0x0526},
+       {0x260e, 0x041f},
+       {0x261c, 0x0433},
+       {0x261d, 0x0434},
+       {0x261e, 0x0432},
+       {0x261f, 0x0435},
+       {0x3004, 0x0420},
+       {0x301d, 0x0538},
+       {0x301f, 0x0539},
+       {0x3020, 0x041e},
+       {0x3094, 0x054c},
+};
+
+static int wchar2sjis_mac_wchar_tbl_len = sizeof(wchar2sjis_mac_wchar_tbl)/(2*sizeof(unsigned short));