Back to index

php5  5.3.10
Defines | Functions | Variables
mysqlnd_charset.c File Reference
#include "php.h"
#include "php_globals.h"
#include "mysqlnd.h"
#include "mysqlnd_priv.h"
#include "mysqlnd_debug.h"

Go to the source code of this file.

Defines

#define valid_big5head(c)   (0xA1 <= (unsigned int)(c) && (unsigned int)(c) <= 0xF9)
#define valid_big5tail(c)
#define isbig5code(c, d)   (isbig5head(c) && isbig5tail(d))
#define valid_cp932head(c)   ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c) && c <= 0xFC))
#define valid_cp932tail(c)   ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && c <= 0xFC))
#define valid_euckr(c)   ((0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE))
#define valid_eucjpms(c)   (((c) & 0xFF) >= 0xA1 && ((c) & 0xFF) <= 0xFE)
#define valid_eucjpms_kata(c)   (((c) & 0xFF) >= 0xA1 && ((c) & 0xFF) <= 0xDF)
#define valid_eucjpms_ss2(c)   (((c) & 0xFF) == 0x8E)
#define valid_eucjpms_ss3(c)   (((c) & 0xFF) == 0x8F)
#define valid_gb2312_head(c)   (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xF7)
#define valid_gb2312_tail(c)   (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE)
#define valid_gbk_head(c)   (0x81<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE)
#define valid_gbk_tail(c)   ((0x40<=(zend_uchar)(c) && (zend_uchar)(c)<=0x7E) || (0x80<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE))
#define valid_sjis_head(c)   ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c) && (c) <= 0xFC))
#define valid_sjis_tail(c)   ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && (c) <= 0xFC))
#define valid_ujis(c)   ((0xA1 <= ((c)&0xFF) && ((c)&0xFF) <= 0xFE))
#define valid_ujis_kata(c)   ((0xA1 <= ((c)&0xFF) && ((c)&0xFF) <= 0xDF))
#define valid_ujis_ss2(c)   (((c)&0xFF) == 0x8E)
#define valid_ujis_ss3(c)   (((c)&0xFF) == 0x8F)
#define UTF16_HIGH_HEAD(x)   ((((zend_uchar) (x)) & 0xFC) == 0xD8)
#define UTF16_LOW_HEAD(x)   ((((zend_uchar) (x)) & 0xFC) == 0xDC)
#define UTF8_MB4   "utf8mb4"
#define UTF8_MB3   "utf8"

Functions

static unsigned int check_mb_utf8mb3_sequence (const char *start, const char *end)
static unsigned int check_mb_utf8_sequence (const char *start, const char *end)
static unsigned int check_mb_utf8mb3_valid (const char *start, const char *end)
static unsigned int check_mb_utf8_valid (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_utf8mb3 (unsigned int utf8)
static unsigned int mysqlnd_mbcharlen_utf8 (unsigned int utf8)
static unsigned int check_mb_big5 (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_big5 (unsigned int big5)
static unsigned int check_mb_cp932 (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_cp932 (unsigned int cp932)
static unsigned int check_mb_euckr (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_euckr (unsigned int kr)
static unsigned int check_mb_eucjpms (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_eucjpms (unsigned int jpms)
static unsigned int check_mb_gb2312 (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_gb2312 (unsigned int gb)
static unsigned int check_mb_gbk (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_gbk (unsigned int gbk)
static unsigned int check_mb_sjis (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_sjis (unsigned int sjis)
static unsigned int check_mb_ucs2 (const char *start __attribute((unused)), const char *end __attribute((unused)))
static unsigned int mysqlnd_mbcharlen_ucs2 (unsigned int ucs2 __attribute((unused)))
static unsigned int check_mb_ujis (const char *start, const char *end)
static unsigned int mysqlnd_mbcharlen_ujis (unsigned int ujis)
static unsigned int check_mb_utf16 (const char *start, const char *end)
static uint mysqlnd_mbcharlen_utf16 (unsigned int utf16)
static uint check_mb_utf32 (const char *start __attribute((unused)), const char *end __attribute((unused)))
static uint mysqlnd_mbcharlen_utf32 (unsigned int utf32 __attribute((unused)))
PHPAPI const MYSQLND_CHARSETmysqlnd_find_charset_nr (unsigned int charsetnr)
PHPAPI const MYSQLND_CHARSETmysqlnd_find_charset_name (const char *const name)
PHPAPI ulong mysqlnd_cset_escape_quotes (const MYSQLND_CHARSET *const cset, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC)
PHPAPI ulong mysqlnd_cset_escape_slashes (const MYSQLND_CHARSET *const cset, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC)

Variables

const MYSQLND_CHARSET mysqlnd_charsets []

Define Documentation

#define isbig5code (   c,
  d 
)    (isbig5head(c) && isbig5tail(d))

Definition at line 196 of file mysqlnd_charset.c.

#define UTF16_HIGH_HEAD (   x)    ((((zend_uchar) (x)) & 0xFC) == 0xD8)

Definition at line 392 of file mysqlnd_charset.c.

#define UTF16_LOW_HEAD (   x)    ((((zend_uchar) (x)) & 0xFC) == 0xDC)

Definition at line 393 of file mysqlnd_charset.c.

#define UTF8_MB3   "utf8"

Definition at line 441 of file mysqlnd_charset.c.

#define UTF8_MB4   "utf8mb4"

Definition at line 440 of file mysqlnd_charset.c.

#define valid_big5head (   c)    (0xA1 <= (unsigned int)(c) && (unsigned int)(c) <= 0xF9)

Definition at line 192 of file mysqlnd_charset.c.

#define valid_big5tail (   c)
Value:
((0x40 <= (unsigned int)(c) && (unsigned int)(c) <= 0x7E) || \
                                                 (0xA1 <= (unsigned int)(c) && (unsigned int)(c) <= 0xFE))

Definition at line 193 of file mysqlnd_charset.c.

#define valid_cp932head (   c)    ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c) && c <= 0xFC))

Definition at line 212 of file mysqlnd_charset.c.

#define valid_cp932tail (   c)    ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && c <= 0xFC))

Definition at line 213 of file mysqlnd_charset.c.

#define valid_eucjpms (   c)    (((c) & 0xFF) >= 0xA1 && ((c) & 0xFF) <= 0xFE)

Definition at line 256 of file mysqlnd_charset.c.

#define valid_eucjpms_kata (   c)    (((c) & 0xFF) >= 0xA1 && ((c) & 0xFF) <= 0xDF)

Definition at line 257 of file mysqlnd_charset.c.

#define valid_eucjpms_ss2 (   c)    (((c) & 0xFF) == 0x8E)

Definition at line 258 of file mysqlnd_charset.c.

#define valid_eucjpms_ss3 (   c)    (((c) & 0xFF) == 0x8F)

Definition at line 259 of file mysqlnd_charset.c.

#define valid_euckr (   c)    ((0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE))

Definition at line 231 of file mysqlnd_charset.c.

#define valid_gb2312_head (   c)    (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xF7)

Definition at line 294 of file mysqlnd_charset.c.

#define valid_gb2312_tail (   c)    (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE)

Definition at line 295 of file mysqlnd_charset.c.

#define valid_gbk_head (   c)    (0x81<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE)

Definition at line 313 of file mysqlnd_charset.c.

#define valid_gbk_tail (   c)    ((0x40<=(zend_uchar)(c) && (zend_uchar)(c)<=0x7E) || (0x80<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE))

Definition at line 314 of file mysqlnd_charset.c.

#define valid_sjis_head (   c)    ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c) && (c) <= 0xFC))

Definition at line 329 of file mysqlnd_charset.c.

#define valid_sjis_tail (   c)    ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && (c) <= 0xFC))

Definition at line 330 of file mysqlnd_charset.c.

#define valid_ujis (   c)    ((0xA1 <= ((c)&0xFF) && ((c)&0xFF) <= 0xFE))

Definition at line 360 of file mysqlnd_charset.c.

#define valid_ujis_kata (   c)    ((0xA1 <= ((c)&0xFF) && ((c)&0xFF) <= 0xDF))

Definition at line 361 of file mysqlnd_charset.c.

#define valid_ujis_ss2 (   c)    (((c)&0xFF) == 0x8E)

Definition at line 362 of file mysqlnd_charset.c.

#define valid_ujis_ss3 (   c)    (((c)&0xFF) == 0x8F)

Definition at line 363 of file mysqlnd_charset.c.


Function Documentation

static unsigned int check_mb_big5 ( const char *  start,
const char *  end 
) [static]

Definition at line 198 of file mysqlnd_charset.c.

{
       return (valid_big5head(*(start)) && (end - start) > 1 && valid_big5tail(*(start + 1)) ? 2 : 0);
}
static unsigned int check_mb_cp932 ( const char *  start,
const char *  end 
) [static]

Definition at line 216 of file mysqlnd_charset.c.

{
       return (valid_cp932head((zend_uchar)start[0]) && (end - start >  1) &&
                     valid_cp932tail((zend_uchar)start[1])) ? 2 : 0;
}
static unsigned int check_mb_eucjpms ( const char *  start,
const char *  end 
) [static]

Definition at line 261 of file mysqlnd_charset.c.

{
       if (*((zend_uchar *)start) < 0x80) {
              return 0;     /* invalid eucjpms character */
       }
       if (valid_eucjpms(start[0]) && (end - start) > 1 && valid_eucjpms(start[1])) {
              return 2;
       }
       if (valid_eucjpms_ss2(start[0]) && (end - start) > 1 && valid_eucjpms_kata(start[1])) {
              return 2;
       }
       if (valid_eucjpms_ss3(start[0]) && (end - start) > 2 && valid_eucjpms(start[1]) &&
              valid_eucjpms(start[2])) {
              return 2;
       }
       return 0;
}
static unsigned int check_mb_euckr ( const char *  start,
const char *  end 
) [static]

Definition at line 233 of file mysqlnd_charset.c.

{
       if (end - start <= 1) {
              return 0;     /* invalid length */
       }
       if (*(zend_uchar *)start < 0x80) {
              return 0;     /* invalid euckr character */
       }
       if (valid_euckr(start[1])) {
              return 2;
       }
       return 0;
}
static unsigned int check_mb_gb2312 ( const char *  start,
const char *  end 
) [static]

Definition at line 298 of file mysqlnd_charset.c.

{
       return (valid_gb2312_head((unsigned int)start[0]) && end - start > 1 &&
                     valid_gb2312_tail((unsigned int)start[1])) ? 2 : 0;
}
static unsigned int check_mb_gbk ( const char *  start,
const char *  end 
) [static]

Definition at line 316 of file mysqlnd_charset.c.

{
       return (valid_gbk_head(start[0]) && (end) - (start) > 1 && valid_gbk_tail(start[1])) ? 2 : 0;
}
static unsigned int check_mb_sjis ( const char *  start,
const char *  end 
) [static]

Definition at line 333 of file mysqlnd_charset.c.

{
       return (valid_sjis_head((zend_uchar)start[0]) && (end - start) > 1 && valid_sjis_tail((zend_uchar)start[1])) ? 2 : 0;
}
static unsigned int check_mb_ucs2 ( const char *start   __attribute(unused),
const char *end   __attribute(unused) 
) [static]

Definition at line 347 of file mysqlnd_charset.c.

{
       return 2; /* always 2 */
}
static unsigned int check_mb_ujis ( const char *  start,
const char *  end 
) [static]

Definition at line 365 of file mysqlnd_charset.c.

{
       if (*(zend_uchar*)start < 0x80) {
              return 0;     /* invalid ujis character */
       }
       if (valid_ujis(*(start)) && valid_ujis(*((start)+1))) {
              return 2;
       }
       if (valid_ujis_ss2(*(start)) && valid_ujis_kata(*((start)+1))) {
              return 2;
       }
       if (valid_ujis_ss3(*(start)) && (end-start) > 2 && valid_ujis(*((start)+1)) && valid_ujis(*((start)+2))) {
              return 3;
       }
       return 0;
}
static unsigned int check_mb_utf16 ( const char *  start,
const char *  end 
) [static]

Definition at line 395 of file mysqlnd_charset.c.

{
       if (start + 2 > end) {
              return 0;
       }

       if (UTF16_HIGH_HEAD(*start)) {
              return (start + 4 <= end) && UTF16_LOW_HEAD(start[2]) ? 4 : 0;
       }

       if (UTF16_LOW_HEAD(*start)) {
              return 0;
       }
       return 2;
}
static uint check_mb_utf32 ( const char *start   __attribute(unused),
const char *end   __attribute(unused) 
) [static]

Definition at line 421 of file mysqlnd_charset.c.

{
       return 4;
}
static unsigned int check_mb_utf8_sequence ( const char *  start,
const char *  end 
) [static]

Definition at line 66 of file mysqlnd_charset.c.

{
       zend_uchar    c;

       if (start >= end) {
              return 0;
       }

       c = (zend_uchar) start[0];

       if (c < 0x80) {
              return 1;            /* single byte character */
       }
       if (c < 0xC2) {
              return 0;            /* invalid mb character */
       }
       if (c < 0xE0) {
              if (start + 2 > end) {
                     return 0;     /* too small */
              }
              if (!(((zend_uchar)start[1] ^ 0x80) < 0x40)) {
                     return 0;
              }
              return 2;
       }
       if (c < 0xF0) {
              if (start + 3 > end) {
                     return 0;     /* too small */
              }
              if (!(((zend_uchar)start[1] ^ 0x80) < 0x40 && ((zend_uchar)start[2] ^ 0x80) < 0x40 &&
                     (c >= 0xE1 || (zend_uchar)start[1] >= 0xA0))) {
                     return 0;     /* invalid utf8 character */
              }
              return 3;
       }
       if (c < 0xF5) {
              if (start + 4 > end) { /* We need 4 characters */
                     return 0;     /* too small */
              }

              /*
                UTF-8 quick four-byte mask:
                11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
                Encoding allows to encode U+00010000..U+001FFFFF

                The maximum character defined in the Unicode standard is U+0010FFFF.
                Higher characters U+00110000..U+001FFFFF are not used.

                11110000.10010000.10xxxxxx.10xxxxxx == F0.90.80.80 == U+00010000 (min)
                11110100.10001111.10111111.10111111 == F4.8F.BF.BF == U+0010FFFF (max)

                Valid codes:
                [F0][90..BF][80..BF][80..BF]
                [F1][80..BF][80..BF][80..BF]
                [F2][80..BF][80..BF][80..BF]
                [F3][80..BF][80..BF][80..BF]
                [F4][80..8F][80..BF][80..BF]
              */

              if (!(((zend_uchar)start[1] ^ 0x80) < 0x40 &&
                     ((zend_uchar)start[2] ^ 0x80) < 0x40 &&
                     ((zend_uchar)start[3] ^ 0x80) < 0x40 &&
                            (c >= 0xf1 || (zend_uchar)start[1] >= 0x90) &&
                            (c <= 0xf3 || (zend_uchar)start[1] <= 0x8F)))
              {
                     return 0;     /* invalid utf8 character */
              }
              return 4;
       }
       return 0;
}

Here is the caller graph for this function:

static unsigned int check_mb_utf8_valid ( const char *  start,
const char *  end 
) [static]

Definition at line 144 of file mysqlnd_charset.c.

{
       unsigned int len = check_mb_utf8_sequence(start, end);
       return (len > 1)? len:0;
}

Here is the call graph for this function:

static unsigned int check_mb_utf8mb3_sequence ( const char *  start,
const char *  end 
) [static]

Definition at line 27 of file mysqlnd_charset.c.

{
       zend_uchar    c;

       if (start >= end) {
              return 0;
       }

       c = (zend_uchar) start[0];

       if (c < 0x80) {
              return 1;            /* single byte character */
       }
       if (c < 0xC2) {
              return 0;            /* invalid mb character */
       }
       if (c < 0xE0) {
              if (start + 2 > end) {
                     return 0;     /* too small */
              }
              if (!(((zend_uchar)start[1] ^ 0x80) < 0x40)) {
                     return 0;
              }
              return 2;
       }
       if (c < 0xF0) {
              if (start + 3 > end) {
                     return 0;     /* too small */
              }
              if (!(((zend_uchar)start[1] ^ 0x80) < 0x40 && ((zend_uchar)start[2] ^ 0x80) < 0x40 &&
                     (c >= 0xE1 || (zend_uchar)start[1] >= 0xA0))) {
                     return 0;     /* invalid utf8 character */
              }
              return 3;
       }
       return 0;
}

Here is the caller graph for this function:

static unsigned int check_mb_utf8mb3_valid ( const char *  start,
const char *  end 
) [static]

Definition at line 138 of file mysqlnd_charset.c.

{
       unsigned int len = check_mb_utf8mb3_sequence(start, end);
       return (len > 1)? len:0;
}

Here is the call graph for this function:

PHPAPI ulong mysqlnd_cset_escape_quotes ( const MYSQLND_CHARSET *const  cset,
char *  newstr,
const char *  escapestr,
size_t escapestr_len  TSRMLS_DC 
)

Definition at line 648 of file mysqlnd_charset.c.

{
       const char    *newstr_s = newstr;
       const char    *newstr_e = newstr + 2 * escapestr_len;
       const char    *end = escapestr + escapestr_len;
       zend_bool     escape_overflow = FALSE;

       DBG_ENTER("mysqlnd_cset_escape_quotes");

       for (;escapestr < end; escapestr++) {
              unsigned int len = 0;
              /* check unicode characters */

              if (cset->char_maxlen > 1 && (len = cset->mb_valid(escapestr, end))) {

                     /* check possible overflow */
                     if ((newstr + len) > newstr_e) {
                            escape_overflow = TRUE;
                            break;
                     }
                     /* copy mb char without escaping it */
                     while (len--) {
                            *newstr++ = *escapestr++;
                     }
                     escapestr--;
                     continue;
              }
              if (*escapestr == '\'') {
                     if (newstr + 2 > newstr_e) {
                            escape_overflow = TRUE;
                            break;
                     }
                     *newstr++ = '\'';
                     *newstr++ = '\'';
              } else {
                     if (newstr + 1 > newstr_e) {
                            escape_overflow = TRUE;
                            break;
                     }
                     *newstr++ = *escapestr;
              }
       }
       *newstr = '\0';

       if (escape_overflow) {
              DBG_RETURN((ulong)~0);
       }
       DBG_RETURN((ulong)(newstr - newstr_s));
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI ulong mysqlnd_cset_escape_slashes ( const MYSQLND_CHARSET *const  cset,
char *  newstr,
const char *  escapestr,
size_t escapestr_len  TSRMLS_DC 
)

Definition at line 702 of file mysqlnd_charset.c.

{
       const char    *newstr_s = newstr;
       const char    *newstr_e = newstr + 2 * escapestr_len;
       const char    *end = escapestr + escapestr_len;
       zend_bool     escape_overflow = FALSE;

       DBG_ENTER("mysqlnd_cset_escape_slashes");
       DBG_INF_FMT("charset=%s", cset->name);

       for (;escapestr < end; escapestr++) {
              char esc = '\0';
              unsigned int len = 0;

              /* check unicode characters */
              if (cset->char_maxlen > 1 && (len = cset->mb_valid(escapestr, end))) {
                     /* check possible overflow */
                     if ((newstr + len) > newstr_e) {
                            escape_overflow = TRUE;
                            break;
                     }
                     /* copy mb char without escaping it */
                     while (len--) {
                            *newstr++ = *escapestr++;
                     }
                     escapestr--;
                     continue;
              }
              if (cset->char_maxlen > 1 && cset->mb_charlen(*escapestr) > 1) {
                     esc = *escapestr;
              } else {
                     switch (*escapestr) {
                            case 0:
                                   esc = '0';
                                   break;
                            case '\n':
                                   esc = 'n';
                                   break;
                            case '\r':
                                   esc = 'r';
                                   break;
                            case '\\':
                            case '\'':
                            case '"':
                                   esc = *escapestr;
                                   break;
                            case '\032':
                                   esc = 'Z';
                                   break;
                     }
              }
              if (esc) {
                     if (newstr + 2 > newstr_e) {
                            escape_overflow = TRUE;
                            break;
                     }
                     /* copy escaped character */
                     *newstr++ = '\\';
                     *newstr++ = esc;
              } else {
                     if (newstr + 1 > newstr_e) {
                            escape_overflow = TRUE;
                            break;
                     }
                     /* copy non escaped character */
                     *newstr++ = *escapestr;
              }
       }
       *newstr = '\0';

       if (escape_overflow) {
              DBG_RETURN((ulong)~0);
       }
       DBG_RETURN((ulong)(newstr - newstr_s));
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI const MYSQLND_CHARSET* mysqlnd_find_charset_name ( const char *const  name)

Definition at line 632 of file mysqlnd_charset.c.

{
       const MYSQLND_CHARSET *c = mysqlnd_charsets;

       do {
              if (!strcasecmp(c->name, name)) {
                     return c;
              }
              ++c;
       } while (c[0].nr != 0);
       return NULL;
}

Here is the caller graph for this function:

PHPAPI const MYSQLND_CHARSET* mysqlnd_find_charset_nr ( unsigned int  charsetnr)

Definition at line 616 of file mysqlnd_charset.c.

{
       const MYSQLND_CHARSET * c = mysqlnd_charsets;

       do {
              if (c->nr == charsetnr) {
                     return c;
              }
              ++c;
       } while (c[0].nr != 0);
       return NULL;
}

Here is the caller graph for this function:

static unsigned int mysqlnd_mbcharlen_big5 ( unsigned int  big5) [static]

Definition at line 204 of file mysqlnd_charset.c.

{
       return (valid_big5head(big5)) ? 2 : 1;
}
static unsigned int mysqlnd_mbcharlen_cp932 ( unsigned int  cp932) [static]

Definition at line 223 of file mysqlnd_charset.c.

{
       return (valid_cp932head((zend_uchar)cp932)) ? 2 : 1;
}
static unsigned int mysqlnd_mbcharlen_eucjpms ( unsigned int  jpms) [static]

Definition at line 280 of file mysqlnd_charset.c.

{
       if (valid_eucjpms(jpms) || valid_eucjpms_ss2(jpms)) {
              return 2;
       }
       if (valid_eucjpms_ss3(jpms)) {
              return 3;
       }
       return 1;
}
static unsigned int mysqlnd_mbcharlen_euckr ( unsigned int  kr) [static]

Definition at line 248 of file mysqlnd_charset.c.

{
       return (valid_euckr(kr)) ? 2 : 1;
}
static unsigned int mysqlnd_mbcharlen_gb2312 ( unsigned int  gb) [static]

Definition at line 305 of file mysqlnd_charset.c.

{
       return (valid_gb2312_head(gb)) ? 2 : 1;
}
static unsigned int mysqlnd_mbcharlen_gbk ( unsigned int  gbk) [static]

Definition at line 321 of file mysqlnd_charset.c.

{
       return (valid_gbk_head(gbk) ? 2 : 1);
}
static unsigned int mysqlnd_mbcharlen_sjis ( unsigned int  sjis) [static]

Definition at line 339 of file mysqlnd_charset.c.

{
       return (valid_sjis_head((zend_uchar)sjis)) ? 2 : 1;
}
static unsigned int mysqlnd_mbcharlen_ucs2 ( unsigned int ucs2   __attribute(unused)) [static]

Definition at line 352 of file mysqlnd_charset.c.

{
       return 2; /* always 2 */
}
static unsigned int mysqlnd_mbcharlen_ujis ( unsigned int  ujis) [static]

Definition at line 383 of file mysqlnd_charset.c.

{
       return (valid_ujis(ujis)? 2: valid_ujis_ss2(ujis)? 2: valid_ujis_ss3(ujis)? 3: 1);
}
static uint mysqlnd_mbcharlen_utf16 ( unsigned int  utf16) [static]

Definition at line 412 of file mysqlnd_charset.c.

{
  return UTF16_HIGH_HEAD(utf16) ? 4 : 2;
}
static uint mysqlnd_mbcharlen_utf32 ( unsigned int utf32   __attribute(unused)) [static]

Definition at line 428 of file mysqlnd_charset.c.

{
       return 4;
}
static unsigned int mysqlnd_mbcharlen_utf8 ( unsigned int  utf8) [static]

Definition at line 169 of file mysqlnd_charset.c.

{
       if (utf8 < 0x80) {
              return 1;            /* single byte character */
       }
       if (utf8 < 0xC2) {
              return 0;            /* invalid multibyte header */
       }
       if (utf8 < 0xE0) {
              return 2;            /* double byte character */
       }
       if (utf8 < 0xF0) {
              return 3;            /* triple byte character */
       }
       if (utf8 < 0xF8) {
              return 4;            /* four byte character */
       }
       return 0;
}
static unsigned int mysqlnd_mbcharlen_utf8mb3 ( unsigned int  utf8) [static]

Definition at line 151 of file mysqlnd_charset.c.

{
       if (utf8 < 0x80) {
              return 1;            /* single byte character */
       }
       if (utf8 < 0xC2) {
              return 0;            /* invalid multibyte header */
       }
       if (utf8 < 0xE0) {
              return 2;            /* double byte character */
       }
       if (utf8 < 0xF0) {
              return 3;            /* triple byte character */
       }
       return 0;
}

Variable Documentation

Definition at line 444 of file mysqlnd_charset.c.