Back to index

php5  5.3.10
Functions | Variables
mbfilter_sjis.h File Reference
#include "mbfilter.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mbfl_filt_conv_sjis_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_sjis (int c, mbfl_convert_filter *filter)

Variables

const mbfl_encoding mbfl_encoding_sjis

Function Documentation

int mbfl_filt_conv_sjis_wchar ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 147 of file mbfilter_sjis.c.

{
       int c1, s1, s2, w;

       switch (filter->status) {
       case 0:
              if (c >= 0 && c < 0x80) {   /* latin */
                     CK((*filter->output_function)(c, filter->data));
              } else if (c > 0xa0 && c < 0xe0) { /* kana */
                     CK((*filter->output_function)(0xfec0 + c, filter->data));
              } else if (c > 0x80 && c < 0xfd && c != 0xa0) {  /* kanji first char */
                     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:              /* kanji second char */
              filter->status = 0;
              c1 = filter->cache;
              if (c >= 0x40 && c <= 0xfc && c != 0x7f) {
                     SJIS_DECODE(c1, c, s1, s2);
                     w = (s1 - 0x21)*94 + s2 - 0x21;
                     if (w >= 0 && w < jisx0208_ucs_table_size) {
                            w = jisx0208_ucs_table[w];
                     } else {
                            w = 0;
                     }
                     if (w <= 0) {
                            if (s1 < 0x7f && s2 < 0x7f) {
                                   w = (s1 << 8) | s2;
                                   w &= MBFL_WCSPLANE_MASK;
                                   w |= MBFL_WCSPLANE_JIS0208;
                            } else {
                                   w = (c1 << 8) | c;
                                   w &= MBFL_WCSGROUP_MASK;
                                   w |= MBFL_WCSGROUP_THROUGH;
                            }
                     }
                     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;

       default:
              filter->status = 0;
              break;
       }

       return c;
}
int mbfl_filt_conv_wchar_sjis ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 212 of file mbfilter_sjis.c.

{
       int c1, c2, s1, s2;

       s1 = 0;
       if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
              s1 = ucs_a1_jis_table[c - ucs_a1_jis_table_min];
       } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) {
              s1 = ucs_a2_jis_table[c - ucs_a2_jis_table_min];
       } else if (c >= ucs_i_jis_table_min && c < ucs_i_jis_table_max) {
              s1 = ucs_i_jis_table[c - ucs_i_jis_table_min];
       } else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) {
              s1 = ucs_r_jis_table[c - ucs_r_jis_table_min];
       }
       if (s1 <= 0) {
              c1 = c & ~MBFL_WCSPLANE_MASK;
              if (c1 == MBFL_WCSPLANE_JIS0208) {
                     s1 = c & MBFL_WCSPLANE_MASK;
              } else if (c == 0xa5) {            /* YEN SIGN */
                     s1 = 0x216f;  /* FULLWIDTH YEN SIGN */
              } else if (c == 0x203e) {   /* OVER LINE */
                     s1 = 0x2131;  /* FULLWIDTH MACRON */
              } else if (c == 0xff3c) {   /* FULLWIDTH REVERSE SOLIDUS */
                     s1 = 0x2140;
              } else if (c == 0xff5e) {   /* FULLWIDTH TILDE */
                     s1 = 0x2141;
              } else if (c == 0x2225) {   /* PARALLEL TO */
                     s1 = 0x2142;
              } else if (c == 0xff0d) {   /* FULLWIDTH HYPHEN-MINUS */
                     s1 = 0x215d;
              } else if (c == 0xffe0) {   /* FULLWIDTH CENT SIGN */
                     s1 = 0x2171;
              } else if (c == 0xffe1) {   /* FULLWIDTH POUND SIGN */
                     s1 = 0x2172;
              } else if (c == 0xffe2) {   /* FULLWIDTH NOT SIGN */
                     s1 = 0x224c;
              }
              if (c == 0) {
                     s1 = 0;
              } else if (s1 <= 0) {
                     s1 = -1;
              }
       } else if (s1 >= 0x8080) {
              s1 = -1;
       }
       if (s1 >= 0) {
              if (s1 < 0x100) { /* latin or kana */
                     CK((*filter->output_function)(s1, filter->data));
              } else { /* kanji */
                     c1 = (s1 >> 8) & 0xff;
                     c2 = s1 & 0xff;
                     SJIS_ENCODE(c1, c2, s1, s2);
                     CK((*filter->output_function)(s1, filter->data));
                     CK((*filter->output_function)(s2, filter->data));
              }
       } else {
              if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
                     CK(mbfl_filt_conv_illegal_output(c, filter));
              }
       }

       return c;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 63 of file mbfilter_sjis.c.