Back to index

php5  5.3.10
Defines | Functions | Variables
mbfilter_uhc.c File Reference
#include "mbfilter.h"
#include "mbfilter_uhc.h"
#include "unicode_table_uhc.h"

Go to the source code of this file.

Defines

#define CK(statement)   do { if ((statement) < 0) return (-1); } while (0)

Functions

static int mbfl_filt_ident_uhc (int c, mbfl_identify_filter *filter)
int mbfl_filt_conv_uhc_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_uhc (int c, mbfl_convert_filter *filter)

Variables

static const unsigned char mblen_table_uhc []
static const char * mbfl_encoding_uhc_aliases [] = {"CP949", NULL}
const mbfl_encoding mbfl_encoding_uhc

Define Documentation

#define CK (   statement)    do { if ((statement) < 0) return (-1); } while (0)

Definition at line 95 of file mbfilter_uhc.c.


Function Documentation

int mbfl_filt_conv_uhc_wchar ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 101 of file mbfilter_uhc.c.

{
       int c1, w = 0, flag = 0;

       switch (filter->status) {
       case 0:
              if (c >= 0 && c < 0x80) {   /* latin */
                     CK((*filter->output_function)(c, filter->data));
              } else if (c > 0x80 && c < 0xff && c != 0xc9) {  /* 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 >= 0x81 && c1 <= 0xa0){
                     w = (c1 - 0x81)*190 + (c - 0x41);
                     if (w >= 0 && w < uhc1_ucs_table_size) {
                            flag = 1;
                            w = uhc1_ucs_table[w];
                     } else {
                            w = 0;
                     }                    
              } else if ( c1 >= 0xa1 && c1 <= 0xc6){
                     w = (c1 - 0xa1)*190 + (c - 0x41);                
                     if (w >= 0 && w < uhc2_ucs_table_size) {
                            flag = 2;
                            w = uhc2_ucs_table[w];
                     } else {
                            w = 0;
                     }                    
              } else if ( c1 >= 0xc7 && c1 <= 0xfe){
                     w = (c1 - 0xc7)*94 + (c - 0xa1);          
                     if (w >= 0 && w < uhc3_ucs_table_size) {
                            flag = 3;
                            w = uhc3_ucs_table[w];
                     } else {
                            w = 0;
                     }                    
              }
              if (flag > 0){
                     if (w <= 0) {
                            w = (c1 << 8) | c;
                            w &= MBFL_WCSPLANE_MASK;
                            w |= MBFL_WCSPLANE_UHC;
                     }
                     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_uhc ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 179 of file mbfilter_uhc.c.

{
       int c1, s;

       s = 0;
       if (c >= ucs_a1_uhc_table_min && c < ucs_a1_uhc_table_max) {
              s = ucs_a1_uhc_table[c - ucs_a1_uhc_table_min];
       } else if (c >= ucs_a2_uhc_table_min && c < ucs_a2_uhc_table_max) {
              s = ucs_a2_uhc_table[c - ucs_a2_uhc_table_min];
       } else if (c >= ucs_a3_uhc_table_min && c < ucs_a3_uhc_table_max) {
              s = ucs_a3_uhc_table[c - ucs_a3_uhc_table_min];
       } else if (c >= ucs_i_uhc_table_min && c < ucs_i_uhc_table_max) {
              s = ucs_i_uhc_table[c - ucs_i_uhc_table_min];
       } else if (c >= ucs_s_uhc_table_min && c < ucs_s_uhc_table_max) {
              s = ucs_s_uhc_table[c - ucs_s_uhc_table_min];
       } else if (c >= ucs_r1_uhc_table_min && c < ucs_r1_uhc_table_max) {
              s = ucs_r1_uhc_table[c - ucs_r1_uhc_table_min];
       } else if (c >= ucs_r2_uhc_table_min && c < ucs_r2_uhc_table_max) {
              s = ucs_r2_uhc_table[c - ucs_r2_uhc_table_min];
       }
       if (s <= 0) {
              c1 = c & ~MBFL_WCSPLANE_MASK;
              if (c1 == MBFL_WCSPLANE_UHC) {
                     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:

static int mbfl_filt_ident_uhc ( int  c,
mbfl_identify_filter *  filter 
) [static]

Definition at line 226 of file mbfilter_uhc.c.

{
       switch (filter->status) {
       case 0: /* latin */
              if (c >= 0 && c < 0x80) { /* ok */
                     ;
              } else if (c >= 0x81 && c <= 0xa0) {      /* dbcs first char */
                  filter->status= 1;
              } else if (c >= 0xa1 && c <= 0xc6) {      /* dbcs first char */
                  filter->status= 2;
              } else if (c >= 0xc7 && c <= 0xfe) {      /* dbcs first char */
                  filter->status= 3;
              } else { /* bad */
                     filter->flag = 1;
              }             

       case 1:
       case 2:
              if (c < 0x41 || (c > 0x5a && c < 0x61)
                     || (c > 0x7a && c < 0x81) || c > 0xfe) {  /* bad */
                  filter->flag = 1;
              }
              filter->status = 0;
              break;

       case 3:
              if (c < 0xa1 || c > 0xfe) { /* bad */
                  filter->flag = 1;
              }
              filter->status = 0;
              break;

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

       return c;
}

Variable Documentation

Initial value:

Definition at line 61 of file mbfilter_uhc.c.

const char* mbfl_encoding_uhc_aliases[] = {"CP949", NULL} [static]

Definition at line 59 of file mbfilter_uhc.c.

const unsigned char mblen_table_uhc[] [static]
Initial value:
 { 
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
}

Definition at line 40 of file mbfilter_uhc.c.