Back to index

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

Go to the source code of this file.

Defines

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

Functions

int mbfl_filt_conv_ucs4_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_ucs4be_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_ucs4be (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_ucs4le_wchar (int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_ucs4le (int c, mbfl_convert_filter *filter)

Variables

static const char * mbfl_encoding_ucs4_aliases [] = {"ISO-10646-UCS-4", "UCS4", NULL}
const mbfl_encoding mbfl_encoding_ucs4
const mbfl_encoding mbfl_encoding_ucs4be
const mbfl_encoding mbfl_encoding_ucs4le

Define Documentation

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

Definition at line 121 of file mbfilter_ucs4.c.


Function Documentation

int mbfl_filt_conv_ucs4_wchar ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 126 of file mbfilter_ucs4.c.

{
       int n, endian;

       endian = filter->status & 0xff00;
       switch (filter->status & 0xff) {
       case 0:
              if (endian) {
                     n = c & 0xff;
              } else {
                     n = (c & 0xff) << 24;
              }
              filter->cache = n;
              filter->status++;
              break;
       case 1:
              if (endian) {
                     n = (c & 0xff) << 8;
              } else {
                     n = (c & 0xff) << 16;
              }
              filter->cache |= n;
              filter->status++;
              break;
       case 2:
              if (endian) {
                     n = (c & 0xff) << 16;
              } else {
                     n = (c & 0xff) << 8;
              }
              filter->cache |= n;
              filter->status++;
              break;
       default:
              if (endian) {
                     n = (c & 0xff) << 24;
              } else {
                     n = c & 0xff;
              }
              n |= filter->cache;
              if ((n & 0xffff) == 0 && ((n >> 16) & 0xffff) == 0xfffe) {
                     if (endian) {
                            filter->status = 0;         /* big-endian */
                     } else {
                            filter->status = 0x100;            /* little-endian */
                     }
                     CK((*filter->output_function)(0xfeff, filter->data));
              } else {
                     filter->status &= ~0xff;
                     CK((*filter->output_function)(n, filter->data));
              }
              break;
       }

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

Definition at line 186 of file mbfilter_ucs4.c.

{
       int n;

       if (filter->status == 0) {
              filter->status = 1;
              n = (c & 0xff) << 24;
              filter->cache = n;
       } else if (filter->status == 1) {
              filter->status = 2;
              n = (c & 0xff) << 16;
              filter->cache |= n;
       } else if (filter->status == 2) {
              filter->status = 3;
              n = (c & 0xff) << 8;
              filter->cache |= n;
       } else {
              filter->status = 0;
              n = (c & 0xff) | filter->cache;
              CK((*filter->output_function)(n, filter->data));
       }
       return c;
}
int mbfl_filt_conv_ucs4le_wchar ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 232 of file mbfilter_ucs4.c.

{
       int n;

       if (filter->status == 0) {
              filter->status = 1;
              n = (c & 0xff);
              filter->cache = n;
       } else if (filter->status == 1) {
              filter->status = 2;
              n = (c & 0xff) << 8;
              filter->cache |= n;
       } else if (filter->status == 2) {
              filter->status = 3;
              n = (c & 0xff) << 16;
              filter->cache |= n;
       } else {
              filter->status = 0;
              n = ((c & 0xff) << 24) | filter->cache;
              CK((*filter->output_function)(n, filter->data));
       }
       return c;
}
int mbfl_filt_conv_wchar_ucs4be ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 213 of file mbfilter_ucs4.c.

{
       if (c >= 0 && c < MBFL_WCSGROUP_UCS4MAX) {
              CK((*filter->output_function)((c >> 24) & 0xff, filter->data));
              CK((*filter->output_function)((c >> 16) & 0xff, filter->data));
              CK((*filter->output_function)((c >> 8) & 0xff, filter->data));
              CK((*filter->output_function)(c & 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:

int mbfl_filt_conv_wchar_ucs4le ( int  c,
mbfl_convert_filter *  filter 
)

Definition at line 259 of file mbfilter_ucs4.c.

{
       if (c >= 0 && c < MBFL_WCSGROUP_UCS4MAX) {
              CK((*filter->output_function)(c & 0xff, filter->data));
              CK((*filter->output_function)((c >> 8) & 0xff, filter->data));
              CK((*filter->output_function)((c >> 16) & 0xff, filter->data));
              CK((*filter->output_function)((c >> 24) & 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

Initial value:
 {
       mbfl_no_encoding_ucs4,
       "UCS-4",
       "UCS-4",
       (const char *(*)[])&mbfl_encoding_ucs4_aliases,
       NULL,
       MBFL_ENCTYPE_WCS4BE
}

Definition at line 39 of file mbfilter_ucs4.c.

const char* mbfl_encoding_ucs4_aliases[] = {"ISO-10646-UCS-4", "UCS4", NULL} [static]

Definition at line 37 of file mbfilter_ucs4.c.

Initial value:
 {
       mbfl_no_encoding_ucs4be,
       "UCS-4BE",
       "UCS-4BE",
       NULL,
       NULL,
       MBFL_ENCTYPE_WCS4BE
}

Definition at line 48 of file mbfilter_ucs4.c.

Initial value:
 {
       mbfl_no_encoding_ucs4le,
       "UCS-4LE",
       "UCS-4LE",
       NULL,
       NULL,
       MBFL_ENCTYPE_WCS4LE
}

Definition at line 57 of file mbfilter_ucs4.c.