Back to index

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

Go to the source code of this file.

Functions

int mbfl_filt_conv_utf8_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_utf8 (int c, mbfl_convert_filter *filter)

Variables

const mbfl_encoding mbfl_encoding_utf8

Function Documentation

int mbfl_filt_conv_utf8_wchar ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 99 of file mbfilter_utf8.c.

{
       int s;

       if (c < 0x80) {
              if (c >= 0) {
                     CK((*filter->output_function)(c, filter->data));
              }
              filter->status = 0;
       } else if (c < 0xc0) {
              int status = filter->status & 0xff;
              switch (status) {
              case 0x10: /* 2byte code 2nd char */
              case 0x21: /* 3byte code 3rd char */
              case 0x32: /* 4byte code 4th char */
              case 0x43: /* 5byte code 5th char */
              case 0x54: /* 6byte code 6th char */
                     filter->status = 0;
                     s = filter->cache | (c & 0x3f);
                     if ((status == 0x10 && s >= 0x80) ||
                         (status == 0x21 && s >= 0x800 && (s < 0xd800 || s > 0xdfff)) ||
                         (status == 0x32 && s >= 0x10000) ||
                         (status == 0x43 && s >= 0x200000) ||
                         (status == 0x54 && s >= 0x4000000 && s < MBFL_WCSGROUP_UCS4MAX)) {
                            CK((*filter->output_function)(s, filter->data));
                     }
                     break;
              case 0x20: /* 3byte code 2nd char */
              case 0x31: /* 4byte code 3rd char */
              case 0x42: /* 5byte code 4th char */
              case 0x53: /* 6byte code 5th char */
                     filter->cache |= ((c & 0x3f) << 6);
                     filter->status++;
                     break;
              case 0x30: /* 4byte code 2nd char */
              case 0x41: /* 5byte code 3rd char */
              case 0x52: /* 6byte code 4th char */
                     filter->cache |= ((c & 0x3f) << 12);
                     filter->status++;
                     break;
              case 0x40: /* 5byte code 2nd char */
              case 0x51: /* 6byte code 3rd char */
                     filter->cache |= ((c & 0x3f) << 18);
                     filter->status++;
                     break;
              case 0x50: /* 6byte code 2nd char */
                     filter->cache |= ((c & 0x3f) << 24);
                     filter->status++;
                     break;
              default:
                     filter->status = 0;
                     break;
              }
       } else if (c < 0xe0) { /* 2byte code first char */
              filter->status = 0x10;
              filter->cache = (c & 0x1f) << 6;
       } else if (c < 0xf0) { /* 3byte code first char */
              filter->status = 0x20;
              filter->cache = (c & 0xf) << 12;
       } else if (c < 0xf8) { /* 4byte code first char */
              filter->status = 0x30;
              filter->cache = (c & 0x7) << 18;
       } else if (c < 0xfc) { /* 5byte code first char */
              filter->status = 0x40;
              filter->cache = (c & 0x3) << 24;
       } else if (c < 0xfe)  { /* 6 byte code first char */
              filter->status = 0x50;
              filter->cache = (c & 0x1) << 30;
       } else {
              filter->status = 0;
              filter->cache = 0;
       }

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

Definition at line 178 of file mbfilter_utf8.c.

{
       if (c >= 0 && c < MBFL_WCSGROUP_UCS4MAX) {
              if (c < 0x80) {
                     CK((*filter->output_function)(c, filter->data));
              } else if (c < 0x800) {
                     CK((*filter->output_function)(((c >> 6) & 0x1f) | 0xc0, filter->data));
                     CK((*filter->output_function)((c & 0x3f) | 0x80, filter->data));
              } else if (c < 0x10000) {
                     CK((*filter->output_function)(((c >> 12) & 0x0f) | 0xe0, filter->data));
                     CK((*filter->output_function)(((c >> 6) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)((c & 0x3f) | 0x80, filter->data));
              } else if (c < 0x200000) {
                     CK((*filter->output_function)(((c >> 18) & 0x07) | 0xf0, filter->data));
                     CK((*filter->output_function)(((c >> 12) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)(((c >> 6) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)((c & 0x3f) | 0x80, filter->data));
              } else if (c < 0x4000000) {
                     CK((*filter->output_function)(((c >> 24) & 0x03) | 0xf8, filter->data));
                     CK((*filter->output_function)(((c >> 18) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)(((c >> 12) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)(((c >> 6) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)((c & 0x3f) | 0x80, filter->data));
              } else {
                     CK((*filter->output_function)(((c >> 30) & 0x01) | 0xfc, filter->data));
                     CK((*filter->output_function)(((c >> 24) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)(((c >> 18) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)(((c >> 12) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)(((c >> 6) & 0x3f) | 0x80, filter->data));
                     CK((*filter->output_function)((c & 0x3f) | 0x80, 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 60 of file mbfilter_utf8.c.