Back to index

php5  5.3.10
Functions | Variables
mbfilter_euc_cn.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_euccn_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_euccn (int c, mbfl_convert_filter *filter)

Variables

const mbfl_encoding mbfl_encoding_euc_cn

Function Documentation

int mbfl_filt_conv_euccn_wchar ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 102 of file mbfilter_euc_cn.c.

{
       int c1, w;

       switch (filter->status) {
       case 0:
              if (c >= 0 && c < 0x80) {   /* latin */
                     CK((*filter->output_function)(c, filter->data));
              } else if (c > 0xa0 && c < 0xff) { /* dbcs 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 second byte */
              filter->status = 0;
              c1 = filter->cache;
              if (c1 > 0xa0 && c1 < 0xff && c > 0xa0 && c < 0xff) {
                     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_GB2312;
                     }
                     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_euccn ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 158 of file mbfilter_euc_cn.c.

{
       int c1, c2, s;

       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_hff_cp936_table_min && c < ucs_hff_cp936_table_max) {
              s = ucs_hff_cp936_table[c - ucs_hff_cp936_table_min];
       }
       c1 = (s >> 8) & 0xff;
       c2 = s & 0xff;
       
       if (c1 < 0xa1 || c2 < 0xa1) { /* exclude CP936 extension */
              s = c;
       }

       if (s <= 0) {
              c1 = c & ~MBFL_WCSPLANE_MASK;
              if (c1 == MBFL_WCSPLANE_GB2312) {
                     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 {
                     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;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 62 of file mbfilter_euc_cn.c.