PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - mysqlnd - mysqlnd_charset.c
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 184
Code covered: 46.7 % Executed lines: 86
Legend: not executed executed

       1                 : /*
       2                 :   +----------------------------------------------------------------------+
       3                 :   | PHP Version 6                                                        |
       4                 :   +----------------------------------------------------------------------+
       5                 :   | Copyright (c) 2006-2009 The PHP Group                                |
       6                 :   +----------------------------------------------------------------------+
       7                 :   | This source file is subject to version 3.01 of the PHP license,      |
       8                 :   | that is bundled with this package in the file LICENSE, and is        |
       9                 :   | available through the world-wide-web at the following url:           |
      10                 :   | http://www.php.net/license/3_01.txt                                  |
      11                 :   | If you did not receive a copy of the PHP license and are unable to   |
      12                 :   | obtain it through the world-wide-web, please send a note to          |
      13                 :   | license@php.net so we can mail you a copy immediately.               |
      14                 :   +----------------------------------------------------------------------+
      15                 :   | Authors: Georg Richter <georg@mysql.com>                             |
      16                 :   |          Andrey Hristov <andrey@mysql.com>                           |
      17                 :   |          Ulf Wendel <uwendel@mysql.com>                              |
      18                 :   +----------------------------------------------------------------------+
      19                 : */
      20                 : #include "php.h"
      21                 : #include "php_globals.h"
      22                 : #include "mysqlnd.h"
      23                 : #include "mysqlnd_priv.h"
      24                 : #include "mysqlnd_debug.h"
      25                 : 
      26                 : /* {{{ utf8 functions */
      27                 : 
      28                 : static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
      29          474933 : {
      30                 :         zend_uchar      c;
      31                 : 
      32          474933 :         if (start >= end) {
      33               0 :                 return 0;
      34                 :         }
      35                 : 
      36          474933 :         c = (zend_uchar) start[0];
      37                 : 
      38          474933 :         if (c < 0x80) {
      39          474828 :                 return 1;               /* single byte character */
      40                 :         }
      41             105 :         if (c < 0xC2) {
      42               0 :                 return 0;               /* invalid mb character */
      43                 :         }
      44             105 :         if (c < 0xE0) {
      45              64 :                 if (start + 2 > end) {
      46               0 :                         return 0;       /* too small */
      47                 :                 }
      48              64 :                 if (!(((zend_uchar)start[1] ^ 0x80) < 0x40)) {
      49               0 :                         return 0;
      50                 :                 }
      51              64 :                 return 2;
      52                 :         }
      53              41 :         if (c < 0xF0) {
      54              41 :                 if (start + 3 > end) {
      55               0 :                         return 0;       /* too small */
      56                 :                 }
      57              41 :                 if (!(((zend_uchar)start[1] ^ 0x80) < 0x40 && ((zend_uchar)start[2] ^ 0x80) < 0x40 &&
      58                 :                         (c >= 0xE1 || (zend_uchar)start[1] >= 0xA0))) {
      59               0 :                         return 0;       /* invalid utf8 character */
      60                 :                 }
      61              41 :                 return 3;
      62                 :         }
      63               0 :         return 0;
      64                 : }
      65                 : 
      66                 : static unsigned int check_mb_utf8_valid(const char *start, const char *end)
      67          474933 : {
      68          474933 :         unsigned int len = check_mb_utf8_sequence(start, end);
      69          474933 :         return (len > 1)? len:0;
      70                 : }
      71                 : 
      72                 : static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
      73          474815 : {
      74          474815 :         if (utf8 < 0x80) {
      75          474815 :                 return 1;               /* single byte character */
      76                 :         }
      77               0 :         if (utf8 < 0xC2) {
      78               0 :                 return 0;               /* invalid multibyte header */
      79                 :         }
      80               0 :         if (utf8 < 0xE0) {
      81               0 :                 return 2;               /* double byte character */
      82                 :         }
      83               0 :         if (utf8 < 0xF0) {
      84               0 :                 return 3;               /* triple byte character */
      85                 :         }
      86                 :         /* We still don't support characters out of the BMP */
      87                 : 
      88               0 :         return 0;
      89                 : }
      90                 : /* }}} */
      91                 : 
      92                 : 
      93                 : /* {{{ big5 functions */
      94                 : #define valid_big5head(c)       (0xA1 <= (unsigned int)(c) && (unsigned int)(c) <= 0xF9)
      95                 : #define valid_big5tail(c)       ((0x40 <= (unsigned int)(c) && (unsigned int)(c) <= 0x7E) || \
      96                 :                                                         (0xA1 <= (unsigned int)(c) && (unsigned int)(c) <= 0xFE))
      97                 : 
      98                 : #define isbig5code(c,d) (isbig5head(c) && isbig5tail(d))
      99                 : 
     100                 : static unsigned int check_mb_big5(const char *start, const char *end)
     101               0 : {
     102               0 :         return (valid_big5head(*(start)) && (end - start) > 1 && valid_big5tail(*(start + 1)) ? 2 : 0);
     103                 : }
     104                 : 
     105                 : 
     106                 : static unsigned int mysqlnd_mbcharlen_big5(unsigned int big5)
     107               0 : {
     108               0 :         return (valid_big5head(big5)) ? 2 : 1;
     109                 : }
     110                 : /* }}} */
     111                 : 
     112                 : 
     113                 : /* {{{ cp932 functions */
     114                 : #define valid_cp932head(c) ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c) && c <= 0xFC))
     115                 : #define valid_cp932tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && c <= 0xFC))
     116                 : 
     117                 : 
     118                 : static unsigned int check_mb_cp932(const char *start, const char *end)
     119               0 : {
     120               0 :         return (valid_cp932head((zend_uchar)start[0]) && (end - start >  1) &&
     121                 :                         valid_cp932tail((zend_uchar)start[1])) ? 2 : 0;
     122                 : }
     123                 : 
     124                 : 
     125                 : static unsigned int mysqlnd_mbcharlen_cp932(unsigned int cp932)
     126               0 : {
     127               0 :         return (valid_cp932head((zend_uchar)cp932)) ? 2 : 1;
     128                 : }
     129                 : /* }}} */
     130                 : 
     131                 : 
     132                 : /* {{{ euckr functions */
     133                 : #define valid_euckr(c)  ((0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE))
     134                 : 
     135                 : static unsigned int check_mb_euckr(const char *start, const char *end)
     136               0 : {
     137               0 :         if (end - start <= 1) {
     138               0 :                 return 0;       /* invalid length */
     139                 :         }
     140               0 :         if (*(zend_uchar *)start < 0x80) {
     141               0 :                 return 0;       /* invalid euckr character */
     142                 :         }
     143               0 :         if (valid_euckr(start[1])) {
     144               0 :                 return 2;
     145                 :         }
     146               0 :         return 0;
     147                 : }
     148                 : 
     149                 : 
     150                 : static unsigned int mysqlnd_mbcharlen_euckr(unsigned int kr)
     151               0 : {
     152               0 :         return (valid_euckr(kr)) ? 2 : 1;
     153                 : }
     154                 : /* }}} */
     155                 : 
     156                 : 
     157                 : /* {{{ eucjpms functions */
     158                 : #define valid_eucjpms(c)                (((c) & 0xFF) >= 0xA1 && ((c) & 0xFF) <= 0xFE)
     159                 : #define valid_eucjpms_kata(c)   (((c) & 0xFF) >= 0xA1 && ((c) & 0xFF) <= 0xDF)
     160                 : #define valid_eucjpms_ss2(c)    (((c) & 0xFF) == 0x8E)
     161                 : #define valid_eucjpms_ss3(c)    (((c) & 0xFF) == 0x8F)
     162                 : 
     163                 : static unsigned int check_mb_eucjpms(const char *start, const char *end)
     164               0 : {
     165               0 :         if (*((zend_uchar *)start) < 0x80) {
     166               0 :                 return 0;       /* invalid eucjpms character */
     167                 :         }
     168               0 :         if (valid_eucjpms(start[0]) && (end - start) > 1 && valid_eucjpms(start[1])) {
     169               0 :                 return 2;
     170                 :         }
     171               0 :         if (valid_eucjpms_ss2(start[0]) && (end - start) > 1 && valid_eucjpms_kata(start[1])) {
     172               0 :                 return 2;
     173                 :         }
     174               0 :         if (valid_eucjpms_ss3(start[0]) && (end - start) > 2 && valid_eucjpms(start[1]) &&
     175                 :                 valid_eucjpms(start[2])) {
     176               0 :                 return 2;
     177                 :         }
     178               0 :         return 0;
     179                 : }
     180                 : 
     181                 : 
     182                 : static unsigned int mysqlnd_mbcharlen_eucjpms(unsigned int jpms)
     183               0 : {
     184               0 :         if (valid_eucjpms(jpms) || valid_eucjpms_ss2(jpms)) {
     185               0 :                 return 2;
     186                 :         }
     187               0 :         if (valid_eucjpms_ss3(jpms)) {
     188               0 :                 return 3;
     189                 :         }
     190               0 :         return 1;
     191                 : }
     192                 : /* }}} */
     193                 : 
     194                 : 
     195                 : /* {{{ gb2312 functions */
     196                 : #define valid_gb2312_head(c)    (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xF7)
     197                 : #define valid_gb2312_tail(c)    (0xA1 <= (zend_uchar)(c) && (zend_uchar)(c) <= 0xFE)
     198                 : 
     199                 : 
     200                 : static unsigned int check_mb_gb2312(const char *start, const char *end)
     201               0 : {
     202               0 :         return (valid_gb2312_head((unsigned int)start[0]) && end - start > 1 &&
     203                 :                         valid_gb2312_tail((unsigned int)start[1])) ? 2 : 0;
     204                 : }
     205                 : 
     206                 : 
     207                 : static unsigned int mysqlnd_mbcharlen_gb2312(unsigned int gb)
     208               0 : {
     209               0 :         return (valid_gb2312_head(gb)) ? 2 : 1;
     210                 : }
     211                 : /* }}} */
     212                 : 
     213                 : 
     214                 : /* {{{ gbk functions */
     215                 : #define valid_gbk_head(c)       (0x81<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE)
     216                 : #define valid_gbk_tail(c)       ((0x40<=(zend_uchar)(c) && (zend_uchar)(c)<=0x7E) || (0x80<=(zend_uchar)(c) && (zend_uchar)(c)<=0xFE))
     217                 : 
     218                 : static unsigned int check_mb_gbk(const char *start, const char *end)
     219               0 : {
     220               0 :         return (valid_gbk_head(start[0]) && (end) - (start) > 1 && valid_gbk_tail(start[1])) ? 2 : 0;
     221                 : }
     222                 : 
     223                 : static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
     224               0 : {
     225               0 :         return (valid_gbk_head(gbk) ? 2 : 1);
     226                 : }
     227                 : /* }}} */
     228                 : 
     229                 : 
     230                 : /* {{{ sjis functions */
     231                 : #define valid_sjis_head(c)      ((0x81 <= (c) && (c) <= 0x9F) && \
     232                 :                                                          (0xE0 <= (c) && (c) <= 0xFC))
     233                 : #define valid_sjis_tail(c)      ((0x40 <= (c) && (c) <= 0x7E) && \
     234                 :                                                          (0x80 <= (c) && (c) <= 0x7C))
     235                 : 
     236                 : 
     237                 : static unsigned int check_mb_sjis(const char *start, const char *end)
     238               0 : {
     239               0 :         return (valid_sjis_head((zend_uchar)start[0]) && (end - start) > 1 && valid_sjis_tail((zend_uchar)start[1])) ? 2 : 0;
     240                 : }
     241                 : 
     242                 : 
     243                 : static unsigned int mysqlnd_mbcharlen_sjis(unsigned int sjis)
     244               0 : {
     245               0 :         return (valid_sjis_head((zend_uchar)sjis)) ? 2 : 1;
     246                 : }
     247                 : /* }}} */
     248                 : 
     249                 : 
     250                 : /* {{{ ucs2 functions */
     251                 : static unsigned int check_mb_ucs2(const char *start __attribute((unused)), const char *end __attribute((unused)))
     252               0 : {
     253               0 :         return 2; /* always 2 */
     254                 : }
     255                 : 
     256                 : static unsigned int mysqlnd_mbcharlen_ucs2(unsigned int ucs2 __attribute((unused)))
     257               0 : {
     258               0 :         return 2; /* always 2 */
     259                 : }
     260                 : /* }}} */
     261                 : 
     262                 : 
     263                 : /* {{{ ujis functions */
     264                 : #define valid_ujis(c)           ((0xA1 <= ((c)&0xFF) && ((c)&0xFF) <= 0xFE))
     265                 : #define valid_ujis_kata(c)  ((0xA1 <= ((c)&0xFF) && ((c)&0xFF) <= 0xDF))
     266                 : #define valid_ujis_ss2(c)       (((c)&0xFF) == 0x8E)
     267                 : #define valid_ujis_ss3(c)       (((c)&0xFF) == 0x8F)
     268                 : 
     269                 : static unsigned int check_mb_ujis(const char *start, const char *end)
     270               0 : {
     271               0 :         if (*(zend_uchar*)start < 0x80) {
     272               0 :                 return 0;       /* invalid ujis character */
     273                 :         }
     274               0 :         if (valid_ujis(*(start)) && valid_ujis(*((start)+1))) {
     275               0 :                 return 2;
     276                 :         }
     277               0 :         if (valid_ujis_ss2(*(start)) && valid_ujis_kata(*((start)+1))) {
     278               0 :                 return 2;
     279                 :         }
     280               0 :         if (valid_ujis_ss3(*(start)) && (end-start) > 2 && valid_ujis(*((start)+1)) && valid_ujis(*((start)+2))) {
     281               0 :                 return 3;
     282                 :         }
     283               0 :         return 0;
     284                 : }
     285                 : 
     286                 : 
     287                 : static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
     288               0 : {
     289               0 :         return (valid_ujis(ujis)? 2: valid_ujis_ss2(ujis)? 2: valid_ujis_ss3(ujis)? 3: 1);
     290                 : }
     291                 : /* }}} */
     292                 : 
     293                 : 
     294                 : 
     295                 : /* {{{ mysqlnd_charsets */
     296                 : const MYSQLND_CHARSET mysqlnd_charsets[] =
     297                 : {
     298                 :         {   1, "big5","big5_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
     299                 :         {   3, "dec8", "dec8_swedisch_ci", 1, 1, "", NULL, NULL},
     300                 :         {   4, "cp850", "cp850_general_ci", 1, 1, "", NULL, NULL},
     301                 :         {   6, "hp8", "hp8_english_ci", 1, 1, "", NULL, NULL},
     302                 :         {   7, "koi8r", "koi8r_general_ci", 1, 1, "", NULL, NULL},
     303                 :         {   8, "latin1", "latin1_swedish_ci", 1, 1, "", NULL, NULL},
     304                 :         {   9, "latin2", "latin2_general_ci", 1, 1, "", NULL, NULL},
     305                 :         {  10, "swe7", "swe7_swedish_ci", 1, 1, "", NULL, NULL},
     306                 :         {  11, "ascii", "ascii_general_ci", 1, 1, "", NULL, NULL},
     307                 :         {  12, "ujis", "ujis_japanese_ci", 1, 3, "", mysqlnd_mbcharlen_ujis, check_mb_ujis},
     308                 :         {  13, "sjis", "sjis_japanese_ci", 1, 2, "", mysqlnd_mbcharlen_sjis, check_mb_sjis},
     309                 :         {  16, "hebrew", "hebrew_general_ci", 1, 1, "", NULL, NULL},
     310                 :         {  18, "tis620", "tis620_thai_ci", 1, 1, "", NULL, NULL},
     311                 :         {  19, "euckr", "euckr_korean_ci", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
     312                 :         {  22, "koi8u", "koi8u_general_ci", 1, 1, "", NULL, NULL},
     313                 :         {  24, "gb2312", "gb2312_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
     314                 :         {  25, "greek", "greek_general_ci", 1, 1, "", NULL, NULL},
     315                 :         {  26, "cp1250", "cp1250_general_ci", 1, 1, "", NULL, NULL},
     316                 :         {  28, "gbk", "gbk_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
     317                 :         {  30, "latin5", "latin5_turkish_ci", 1, 1, "", NULL, NULL},
     318                 :         {  32, "armscii8", "armscii8_general_ci", 1, 1, "", NULL, NULL},
     319                 :         {  33, "utf8", "utf8_general_ci", 1, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
     320                 :         {  35, "ucs2", "ucs2_general_ci", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     321                 :         {  36, "cp866", "cp866_general_ci", 1, 1, "", NULL, NULL},
     322                 :         {  37, "keybcs2", "keybcs2_general_ci", 1, 1, "", NULL, NULL},
     323                 :         {  38, "macce", "macce_general_ci", 1, 1, "", NULL, NULL},
     324                 :         {  39, "macroman", "macroman_general_ci", 1, 1, "", NULL, NULL},
     325                 :         {  40, "cp852", "cp852_general_ci", 1, 1, "", NULL, NULL},
     326                 :         {  41, "latin7", "latin7_general_ci", 1, 1, "", NULL, NULL},
     327                 :         {  51, "cp1251", "cp1251_general_ci", 1, 1, "", NULL, NULL},
     328                 :         {  57, "cp1256", "cp1256_general_ci", 1, 1, "", NULL, NULL},
     329                 :         {  59, "cp1257", "cp1257_general_ci", 1, 1, "", NULL, NULL},
     330                 :         {  63, "binary", "binary", 1, 1, "", NULL, NULL},
     331                 :         {  92, "geostd8", "geostd8_general_ci", 1, 1, "", NULL, NULL},
     332                 :         {  95, "cp932", "cp932_japanese_ci", 1, 2, "", mysqlnd_mbcharlen_cp932, check_mb_cp932},
     333                 :         {  97, "eucjpms", "eucjpms_japanese_ci", 1, 3, "", mysqlnd_mbcharlen_eucjpms, check_mb_eucjpms},
     334                 :         {   2, "latin2", "latin2_czech_cs", 1, 1, "", NULL, NULL},
     335                 :         {   5, "latin1", "latin1_german_ci", 1, 1, "", NULL, NULL},
     336                 :         {  14, "cp1251", "cp1251_bulgarian_ci", 1, 1, "", NULL, NULL},
     337                 :         {  15, "latin1", "latin1_danish_ci", 1, 1, "", NULL, NULL},
     338                 :         {  17, "filename", "filename", 1, 5, "", NULL, NULL},
     339                 :         {  20, "latin7", "latin7_estonian_cs", 1, 1, "", NULL, NULL},
     340                 :         {  21, "latin2", "latin2_hungarian_ci", 1, 1, "", NULL, NULL},
     341                 :         {  23, "cp1251", "cp1251_ukrainian_ci", 1, 1, "", NULL, NULL},
     342                 :         {  27, "latin2", "latin2_croatian_ci", 1, 1, "", NULL, NULL},
     343                 :         {  29, "cp1257", "cp1257_lithunian_ci", 1, 1, "", NULL, NULL},
     344                 :         {  31, "latin1", "latin1_german2_ci", 1, 1, "", NULL, NULL},
     345                 :         {  34, "cp1250", "cp1250_czech_cs", 1, 1, "", NULL, NULL},
     346                 :         {  42, "latin7", "latin7_general_cs", 1, 1, "", NULL, NULL},
     347                 :         {  43, "macce", "macce_bin", 1, 1, "", NULL, NULL},
     348                 :         {  44, "cp1250", "cp1250_croatian_ci", 1, 1, "", NULL, NULL},
     349                 :         {  47, "latin1", "latin1_bin", 1, 1, "", NULL, NULL},
     350                 :         {  48, "latin1", "latin1_general_ci", 1, 1, "", NULL, NULL},
     351                 :         {  49, "latin1", "latin1_general_cs", 1, 1, "", NULL, NULL},
     352                 :         {  50, "cp1251", "cp1251_bin", 1, 1, "", NULL, NULL},
     353                 :         {  52, "cp1251", "cp1251_general_cs", 1, 1, "", NULL, NULL},
     354                 :         {  53, "macroman", "macroman_bin", 1, 1, "", NULL, NULL},
     355                 :         {  58, "cp1257", "cp1257_bin", 1, 1, "", NULL, NULL},
     356                 :         {  60, "armascii8", "armascii8_bin", 1, 1, "", NULL, NULL},
     357                 :         {  65, "ascii", "ascii_bin", 1, 1, "", NULL, NULL},
     358                 :         {  66, "cp1250", "cp1250_bin", 1, 1, "", NULL, NULL},
     359                 :         {  67, "cp1256", "cp1256_bin", 1, 1, "", NULL, NULL},
     360                 :         {  68, "cp866", "cp866_bin", 1, 1, "", NULL, NULL},
     361                 :         {  69, "dec8", "dec8_bin", 1, 1, "", NULL, NULL},
     362                 :         {  70, "greek", "greek_bin", 1, 1, "", NULL, NULL},
     363                 :         {  71, "hebew", "hebrew_bin", 1, 1, "", NULL, NULL},
     364                 :         {  72, "hp8", "hp8_bin", 1, 1, "", NULL, NULL},
     365                 :         {  73, "keybcs2", "keybcs2_bin", 1, 1, "", NULL, NULL},
     366                 :         {  74, "koi8r", "koi8r_bin", 1, 1, "", NULL, NULL},
     367                 :         {  75, "koi8u", "koi8u_bin", 1, 1, "", NULL, NULL},
     368                 :         {  77, "latin2", "latin2_bin", 1, 1, "", NULL, NULL},
     369                 :         {  78, "latin5", "latin5_bin", 1, 1, "", NULL, NULL},
     370                 :         {  79, "latin7", "latin7_bin", 1, 1, "", NULL, NULL},
     371                 :         {  80, "cp850", "cp850_bin", 1, 1, "", NULL, NULL},
     372                 :         {  81, "cp852", "cp852_bin", 1, 1, "", NULL, NULL},
     373                 :         {  82, "swe7", "swe7_bin", 1, 1, "", NULL, NULL},
     374                 :         {  93, "geostd8", "geostd8_bin", 1, 1, "", NULL, NULL},
     375                 :         {  83, "utf8", "utf8_bin", 1, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
     376                 :         {  84, "big5", "big5_bin", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
     377                 :         {  85, "euckr", "euckr_bin", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
     378                 :         {  86, "gb2312", "gb2312_bin", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
     379                 :         {  87, "gbk", "gbk_bin", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
     380                 :         {  88, "sjis", "sjis_bin", 1, 2, "", mysqlnd_mbcharlen_sjis, check_mb_sjis},
     381                 :         {  89, "tis620", "tis620_bin", 1, 1, "", NULL, NULL},
     382                 :         {  90, "ucs2", "ucs2_bin", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     383                 :         {  91, "ujis", "ujis_bin", 1, 3, "", mysqlnd_mbcharlen_ujis, check_mb_ujis},
     384                 :         {  94, "latin1", "latin1_spanish_ci", 1, 1, "", NULL, NULL},
     385                 :         {  96, "cp932", "cp932_bin", 1, 2, "", mysqlnd_mbcharlen_cp932, check_mb_cp932},
     386                 :         {  99, "cp1250", "cp1250_polish_ci", 1, 1, "", NULL, NULL},
     387                 :         {  98, "eucjpms", "eucjpms_bin", 1, 3, "", mysqlnd_mbcharlen_eucjpms, check_mb_eucjpms},
     388                 :         { 128, "ucs2", "ucs2_unicode_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     389                 :         { 129, "ucs2", "ucs2_icelandic_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     390                 :         { 130, "ucs2", "ucs2_latvian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     391                 :         { 131, "ucs2", "ucs2_romanian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     392                 :         { 132, "ucs2", "ucs2_slovenian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     393                 :         { 133, "ucs2", "ucs2_polish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     394                 :         { 134, "ucs2", "ucs2_estonian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     395                 :         { 135, "ucs2", "ucs2_spanish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     396                 :         { 136, "ucs2", "ucs2_swedish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     397                 :         { 137, "ucs2", "ucs2_turkish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     398                 :         { 138, "ucs2", "ucs2_czech_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     399                 :         { 139, "ucs2", "ucs2_danish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     400                 :         { 140, "ucs2", "ucs2_lithunian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     401                 :         { 141, "ucs2", "ucs2_slovak_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     402                 :         { 142, "ucs2", "ucs2_spanish2_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     403                 :         { 143, "ucs2", "ucs2_roman_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     404                 :         { 144, "ucs2", "ucs2_persian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     405                 :         { 145, "ucs2", "ucs2_esperanto_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     406                 :         { 146, "ucs2", "ucs2_hungarian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     407                 :         { 147, "ucs2", "ucs2_sinhala_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     408                 :         { 192, "utf8", "utf8_general_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     409                 :         { 193, "utf8", "utf8_icelandic_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     410                 :         { 194, "utf8", "utf8_latvian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
     411                 :         { 195, "utf8", "utf8_romanian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     412                 :         { 196, "utf8", "utf8_slovenian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     413                 :         { 197, "utf8", "utf8_polish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     414                 :         { 198, "utf8", "utf8_estonian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     415                 :         { 119, "utf8", "utf8_spanish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     416                 :         { 200, "utf8", "utf8_swedish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     417                 :         { 201, "utf8", "utf8_turkish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     418                 :         { 202, "utf8", "utf8_czech_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     419                 :         { 203, "utf8", "utf8_danish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
     420                 :         { 204, "utf8", "utf8_lithunian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
     421                 :         { 205, "utf8", "utf8_slovak_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     422                 :         { 206, "utf8", "utf8_spanish2_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     423                 :         { 207, "utf8", "utf8_roman_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     424                 :         { 208, "utf8", "utf8_persian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     425                 :         { 209, "utf8", "utf8_esperanto_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     426                 :         { 210, "utf8", "utf8_hungarian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     427                 :         { 254, "utf8", "utf8_general_cs", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     428                 :         {   0, NULL, NULL, 0, 0, NULL, NULL, NULL}
     429                 : };
     430                 : /* }}} */
     431                 : 
     432                 : 
     433                 : /* {{{ mysqlnd_charsets */
     434                 : const MYSQLND_CHARSET mysqlnd_charsets60[] =
     435                 : {
     436                 :         {   1, "big5","big5_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
     437                 :         {   3, "dec8", "dec8_swedisch_ci", 1, 1, "", NULL, NULL},
     438                 :         {   4, "cp850", "cp850_general_ci", 1, 1, "", NULL, NULL},
     439                 :         {   6, "hp8", "hp8_english_ci", 1, 1, "", NULL, NULL},
     440                 :         {   7, "koi8r", "koi8r_general_ci", 1, 1, "", NULL, NULL},
     441                 :         {   8, "latin1", "latin1_swedish_ci", 1, 1, "", NULL, NULL},
     442                 :         {   9, "latin2", "latin2_general_ci", 1, 1, "", NULL, NULL},
     443                 :         {  10, "swe7", "swe7_swedish_ci", 1, 1, "", NULL, NULL},
     444                 :         {  11, "ascii", "ascii_general_ci", 1, 1, "", NULL, NULL},
     445                 :         {  12, "ujis", "ujis_japanese_ci", 1, 3, "", mysqlnd_mbcharlen_ujis, check_mb_ujis},
     446                 :         {  13, "sjis", "sjis_japanese_ci", 1, 2, "", mysqlnd_mbcharlen_sjis, check_mb_sjis},
     447                 :         {  16, "hebrew", "hebrew_general_ci", 1, 1, "", NULL, NULL},
     448                 :         {  18, "tis620", "tis620_thai_ci", 1, 1, "", NULL, NULL},
     449                 :         {  19, "euckr", "euckr_korean_ci", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
     450                 :         {  22, "koi8u", "koi8u_general_ci", 1, 1, "", NULL, NULL},
     451                 :         {  24, "gb2312", "gb2312_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
     452                 :         {  25, "greek", "greek_general_ci", 1, 1, "", NULL, NULL},
     453                 :         {  26, "cp1250", "cp1250_general_ci", 1, 1, "", NULL, NULL},
     454                 :         {  28, "gbk", "gbk_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
     455                 :         {  30, "latin5", "latin5_turkish_ci", 1, 1, "", NULL, NULL},
     456                 :         {  32, "armscii8", "armscii8_general_ci", 1, 1, "", NULL, NULL},
     457                 :         {  33, "utf8", "utf8_general_ci", 1, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
     458                 :         {  35, "ucs2", "ucs2_general_ci", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     459                 :         {  36, "cp866", "cp866_general_ci", 1, 1, "", NULL, NULL},
     460                 :         {  37, "keybcs2", "keybcs2_general_ci", 1, 1, "", NULL, NULL},
     461                 :         {  38, "macce", "macce_general_ci", 1, 1, "", NULL, NULL},
     462                 :         {  39, "macroman", "macroman_general_ci", 1, 1, "", NULL, NULL},
     463                 :         {  40, "cp852", "cp852_general_ci", 1, 1, "", NULL, NULL},
     464                 :         {  41, "latin7", "latin7_general_ci", 1, 1, "", NULL, NULL},
     465                 :         {  51, "cp1251", "cp1251_general_ci", 1, 1, "", NULL, NULL},
     466                 :         {  57, "cp1256", "cp1256_general_ci", 1, 1, "", NULL, NULL},
     467                 :         {  59, "cp1257", "cp1257_general_ci", 1, 1, "", NULL, NULL},
     468                 :         {  63, "binary", "binary", 1, 1, "", NULL, NULL},
     469                 :         {  92, "geostd8", "geostd8_general_ci", 1, 1, "", NULL, NULL},
     470                 :         {  95, "cp932", "cp932_japanese_ci", 1, 2, "", mysqlnd_mbcharlen_cp932, check_mb_cp932},
     471                 :         {  97, "eucjpms", "eucjpms_japanese_ci", 1, 3, "", mysqlnd_mbcharlen_eucjpms, check_mb_eucjpms},
     472                 :         {   2, "latin2", "latin2_czech_cs", 1, 1, "", NULL, NULL},
     473                 :         {   5, "latin1", "latin1_german_ci", 1, 1, "", NULL, NULL},
     474                 :         {  14, "cp1251", "cp1251_bulgarian_ci", 1, 1, "", NULL, NULL},
     475                 :         {  15, "latin1", "latin1_danish_ci", 1, 1, "", NULL, NULL},
     476                 :         {  17, "filename", "filename", 1, 5, "", NULL, NULL},
     477                 :         {  20, "latin7", "latin7_estonian_cs", 1, 1, "", NULL, NULL},
     478                 :         {  21, "latin2", "latin2_hungarian_ci", 1, 1, "", NULL, NULL},
     479                 :         {  23, "cp1251", "cp1251_ukrainian_ci", 1, 1, "", NULL, NULL},
     480                 :         {  27, "latin2", "latin2_croatian_ci", 1, 1, "", NULL, NULL},
     481                 :         {  29, "cp1257", "cp1257_lithunian_ci", 1, 1, "", NULL, NULL},
     482                 :         {  31, "latin1", "latin1_german2_ci", 1, 1, "", NULL, NULL},
     483                 :         {  34, "cp1250", "cp1250_czech_cs", 1, 1, "", NULL, NULL},
     484                 :         {  42, "latin7", "latin7_general_cs", 1, 1, "", NULL, NULL},
     485                 :         {  43, "macce", "macce_bin", 1, 1, "", NULL, NULL},
     486                 :         {  44, "cp1250", "cp1250_croatian_ci", 1, 1, "", NULL, NULL},
     487                 :         {  47, "latin1", "latin1_bin", 1, 1, "", NULL, NULL},
     488                 :         {  48, "latin1", "latin1_general_ci", 1, 1, "", NULL, NULL},
     489                 :         {  49, "latin1", "latin1_general_cs", 1, 1, "", NULL, NULL},
     490                 :         {  50, "cp1251", "cp1251_bin", 1, 1, "", NULL, NULL},
     491                 :         {  52, "cp1251", "cp1251_general_cs", 1, 1, "", NULL, NULL},
     492                 :         {  53, "macroman", "macroman_bin", 1, 1, "", NULL, NULL},
     493                 :         {  58, "cp1257", "cp1257_bin", 1, 1, "", NULL, NULL},
     494                 :         {  60, "armascii8", "armascii8_bin", 1, 1, "", NULL, NULL},
     495                 :         {  65, "ascii", "ascii_bin", 1, 1, "", NULL, NULL},
     496                 :         {  66, "cp1250", "cp1250_bin", 1, 1, "", NULL, NULL},
     497                 :         {  67, "cp1256", "cp1256_bin", 1, 1, "", NULL, NULL},
     498                 :         {  68, "cp866", "cp866_bin", 1, 1, "", NULL, NULL},
     499                 :         {  69, "dec8", "dec8_bin", 1, 1, "", NULL, NULL},
     500                 :         {  70, "greek", "greek_bin", 1, 1, "", NULL, NULL},
     501                 :         {  71, "hebew", "hebrew_bin", 1, 1, "", NULL, NULL},
     502                 :         {  72, "hp8", "hp8_bin", 1, 1, "", NULL, NULL},
     503                 :         {  73, "keybcs2", "keybcs2_bin", 1, 1, "", NULL, NULL},
     504                 :         {  74, "koi8r", "koi8r_bin", 1, 1, "", NULL, NULL},
     505                 :         {  75, "koi8u", "koi8u_bin", 1, 1, "", NULL, NULL},
     506                 :         {  77, "latin2", "latin2_bin", 1, 1, "", NULL, NULL},
     507                 :         {  78, "latin5", "latin5_bin", 1, 1, "", NULL, NULL},
     508                 :         {  79, "latin7", "latin7_bin", 1, 1, "", NULL, NULL},
     509                 :         {  80, "cp850", "cp850_bin", 1, 1, "", NULL, NULL},
     510                 :         {  81, "cp852", "cp852_bin", 1, 1, "", NULL, NULL},
     511                 :         {  82, "swe7", "swe7_bin", 1, 1, "", NULL, NULL},
     512                 :         {  93, "geostd8", "geostd8_bin", 1, 1, "", NULL, NULL},
     513                 :         {  83, "utf8", "utf8_bin", 1, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
     514                 :         {  84, "big5", "big5_bin", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
     515                 :         {  85, "euckr", "euckr_bin", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
     516                 :         {  86, "gb2312", "gb2312_bin", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
     517                 :         {  87, "gbk", "gbk_bin", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
     518                 :         {  88, "sjis", "sjis_bin", 1, 2, "", mysqlnd_mbcharlen_sjis, check_mb_sjis},
     519                 :         {  89, "tis620", "tis620_bin", 1, 1, "", NULL, NULL},
     520                 :         {  90, "ucs2", "ucs2_bin", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     521                 :         {  91, "ujis", "ujis_bin", 1, 3, "", mysqlnd_mbcharlen_ujis, check_mb_ujis},
     522                 :         {  94, "latin1", "latin1_spanish_ci", 1, 1, "", NULL, NULL},
     523                 :         {  96, "cp932", "cp932_bin", 1, 2, "", mysqlnd_mbcharlen_cp932, check_mb_cp932},
     524                 :         {  99, "cp1250", "cp1250_polish_ci", 1, 1, "", NULL, NULL},
     525                 :         {  98, "eucjpms", "eucjpms_bin", 1, 3, "", mysqlnd_mbcharlen_eucjpms, check_mb_eucjpms},
     526                 :         { 128, "ucs2", "ucs2_unicode_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     527                 :         { 129, "ucs2", "ucs2_icelandic_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     528                 :         { 130, "ucs2", "ucs2_latvian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     529                 :         { 131, "ucs2", "ucs2_romanian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     530                 :         { 132, "ucs2", "ucs2_slovenian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     531                 :         { 133, "ucs2", "ucs2_polish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     532                 :         { 134, "ucs2", "ucs2_estonian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     533                 :         { 135, "ucs2", "ucs2_spanish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     534                 :         { 136, "ucs2", "ucs2_swedish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     535                 :         { 137, "ucs2", "ucs2_turkish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     536                 :         { 138, "ucs2", "ucs2_czech_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     537                 :         { 139, "ucs2", "ucs2_danish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     538                 :         { 140, "ucs2", "ucs2_lithunian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     539                 :         { 141, "ucs2", "ucs2_slovak_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     540                 :         { 142, "ucs2", "ucs2_spanish2_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     541                 :         { 143, "ucs2", "ucs2_roman_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     542                 :         { 144, "ucs2", "ucs2_persian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     543                 :         { 145, "ucs2", "ucs2_esperanto_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     544                 :         { 146, "ucs2", "ucs2_hungarian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     545                 :         { 147, "ucs2", "ucs2_sinhala_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
     546                 :         { 192, "utf8mb3", "utf8mb3_general_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     547                 :         { 193, "utf8mb3", "utf8mb3_icelandic_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     548                 :         { 194, "utf8mb3", "utf8mb3_latvian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
     549                 :         { 195, "utf8mb3", "utf8mb3_romanian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     550                 :         { 196, "utf8mb3", "utf8mb3_slovenian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     551                 :         { 197, "utf8mb3", "utf8mb3_polish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     552                 :         { 198, "utf8mb3", "utf8mb3_estonian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     553                 :         { 119, "utf8mb3", "utf8mb3_spanish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     554                 :         { 200, "utf8mb3", "utf8mb3_swedish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     555                 :         { 201, "utf8mb3", "utf8mb3_turkish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     556                 :         { 202, "utf8mb3", "utf8mb3_czech_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     557                 :         { 203, "utf8mb3", "utf8mb3_danish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
     558                 :         { 204, "utf8mb3", "utf8mb3_lithunian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
     559                 :         { 205, "utf8mb3", "utf8mb3_slovak_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     560                 :         { 206, "utf8mb3", "utf8mb3_spanish2_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     561                 :         { 207, "utf8mb3", "utf8mb3_roman_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     562                 :         { 208, "utf8mb3", "utf8mb3_persian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     563                 :         { 209, "utf8mb3", "utf8mb3_esperanto_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     564                 :         { 210, "utf8mb3", "utf8mb3_hungarian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     565                 :         { 211, "utf8mb3", "utf8mb3_sinhala_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     566                 :         { 224, "utf8", "utf8_unicode_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     567                 :         { 225, "utf8", "utf8_icelandic_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     568                 :         { 226, "utf8", "utf8_latvian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     569                 :         { 227, "utf8", "utf8_romanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     570                 :         { 228, "utf8", "utf8_slovenian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     571                 :         { 229, "utf8", "utf8_polish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     572                 :         { 230, "utf8", "utf8_estonian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     573                 :         { 231, "utf8", "utf8_spanish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     574                 :         { 232, "utf8", "utf8_swedish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     575                 :         { 233, "utf8", "utf8_turkish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     576                 :         { 234, "utf8", "utf8_czech_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     577                 :         { 235, "utf8", "utf8_danish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     578                 :         { 236, "utf8", "utf8_lithuanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     579                 :         { 237, "utf8", "utf8_slovak_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     580                 :         { 238, "utf8", "utf8_spanish2_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     581                 :         { 239, "utf8", "utf8_roman_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     582                 :         { 240, "utf8", "utf8_persian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     583                 :         { 241, "utf8", "utf8_esperanto_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     584                 :         { 242, "utf8", "utf8_hungarian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     585                 :         { 243, "utf8", "utf8_sinhala_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     586                 :         { 254, "utf8mb3", "utf8mb3_general_cs", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
     587                 :         {   0, NULL, NULL, 0, 0, NULL, NULL, NULL}
     588                 : };
     589                 : /* }}} */
     590                 : 
     591                 : 
     592                 : /* {{{ mysqlnd_find_charset_nr */
     593                 : PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(unsigned int charsetnr)
     594            3215 : {
     595            3215 :         const MYSQLND_CHARSET * c = mysqlnd_charsets;
     596                 : 
     597                 :         do {
     598           85276 :                 if (c->nr == charsetnr) {
     599            3215 :                         return c;
     600                 :                 }
     601           82061 :                 ++c;
     602           82061 :         } while (c[0].nr != 0);
     603               0 :         return NULL;
     604                 : }
     605                 : /* }}} */
     606                 : 
     607                 : 
     608                 : /* {{{ mysqlnd_find_charset_name */
     609                 : PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const name)
     610            1218 : {
     611            1218 :         const MYSQLND_CHARSET *c = mysqlnd_charsets;
     612                 : 
     613                 :         do {
     614           26668 :                 if (!strcasecmp(c->name, name)) {
     615            1218 :                         return c;
     616                 :                 }
     617           25450 :                 ++c;
     618           25450 :         } while (c[0].nr != 0);
     619               0 :         return NULL;
     620                 : }
     621                 : /* }}} */
     622                 : 
     623                 : 
     624                 : /* {{{ mysqlnd_cset_escape_quotes */
     625                 : PHPAPI ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, char *newstr,
     626                 :                                                                                 const char *escapestr, size_t escapestr_len TSRMLS_DC)
     627               7 : {
     628               7 :         const char      *newstr_s = newstr;
     629               7 :         const char      *newstr_e = newstr + 2 * escapestr_len;
     630               7 :         const char      *end = escapestr + escapestr_len;
     631               7 :         zend_bool       escape_overflow = FALSE;
     632                 : 
     633               7 :         DBG_ENTER("mysqlnd_cset_escape_quotes");
     634                 : 
     635              20 :         for (;escapestr < end; escapestr++) {
     636              13 :                 unsigned int len = 0;
     637                 :                 /* check unicode characters */
     638                 : 
     639              13 :                 if (cset->char_maxlen > 1 && (len = cset->mb_valid(escapestr, end))) {
     640                 : 
     641                 :                         /* check possible overflow */
     642               0 :                         if ((newstr + len) > newstr_e) {
     643               0 :                                 escape_overflow = TRUE;
     644               0 :                                 break;
     645                 :                         }
     646                 :                         /* copy mb char without escaping it */
     647               0 :                         while (len--) {
     648               0 :                                 *newstr++ = *escapestr++;
     649                 :                         }
     650               0 :                         escapestr--;
     651               0 :                         continue;
     652                 :                 }
     653              13 :                 if (*escapestr == '\'') {
     654               1 :                         if (newstr + 2 > newstr_e) {
     655               0 :                                 escape_overflow = TRUE;
     656               0 :                                 break;
     657                 :                         }
     658               1 :                         *newstr++ = '\'';
     659               1 :                         *newstr++ = '\'';
     660                 :                 } else {
     661              12 :                         if (newstr + 1 > newstr_e) {
     662               0 :                                 escape_overflow = TRUE;
     663               0 :                                 break;
     664                 :                         }
     665              12 :                         *newstr++ = *escapestr;
     666                 :                 }
     667                 :         }
     668               7 :         *newstr = '\0';
     669                 : 
     670               7 :         if (escape_overflow) {
     671               0 :                 DBG_RETURN((ulong)~0);
     672                 :         }
     673               7 :         DBG_RETURN((ulong)(newstr - newstr_s));
     674                 : }
     675                 : /* }}} */
     676                 : 
     677                 : 
     678                 : /* {{{ mysqlnd_cset_escape_slashes */
     679                 : PHPAPI ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char *newstr,
     680                 :                                                                                  const char *escapestr, size_t escapestr_len TSRMLS_DC)
     681            3023 : {
     682            3023 :         const char      *newstr_s = newstr;
     683            3023 :         const char      *newstr_e = newstr + 2 * escapestr_len;
     684            3023 :         const char      *end = escapestr + escapestr_len;
     685            3023 :         zend_bool       escape_overflow = FALSE;
     686                 : 
     687            3023 :         DBG_ENTER("mysqlnd_cset_escape_slashes");
     688            3023 :         DBG_INF_FMT("charset=%s", cset->name);
     689                 : 
     690          478021 :         for (;escapestr < end; escapestr++) {
     691          474998 :                 char esc = '\0';
     692          474998 :                 unsigned int len = 0;
     693                 : 
     694                 :                 /* check unicode characters */
     695          474998 :                 if (cset->char_maxlen > 1 && (len = cset->mb_valid(escapestr, end))) {
     696                 :                         /* check possible overflow */
     697             105 :                         if ((newstr + len) > newstr_e) {
     698               0 :                                 escape_overflow = TRUE;
     699               0 :                                 break;
     700                 :                         }
     701                 :                         /* copy mb char without escaping it */
     702             461 :                         while (len--) {
     703             251 :                                 *newstr++ = *escapestr++;
     704                 :                         }
     705             105 :                         escapestr--;
     706             105 :                         continue;
     707                 :                 }
     708          474893 :                 if (cset->char_maxlen > 1 && cset->mb_charlen(*escapestr) > 1) {
     709               0 :                         esc = *escapestr;
     710                 :                 } else {
     711          474893 :                         switch (*escapestr) {
     712                 :                                 case 0:
     713              10 :                                         esc = '0';
     714              10 :                                         break;
     715                 :                                 case '\n':
     716               8 :                                         esc = 'n';
     717               8 :                                         break;
     718                 :                                 case '\r':
     719               7 :                                         esc = 'r';
     720               7 :                                         break;
     721                 :                                 case '\\':
     722                 :                                 case '\'':
     723                 :                                 case '"':
     724              81 :                                         esc = *escapestr;
     725              81 :                                         break;
     726                 :                                 case '\032':
     727               2 :                                         esc = 'Z';
     728                 :                                         break;
     729                 :                         }
     730                 :                 }
     731          474893 :                 if (esc) {
     732             108 :                         if (newstr + 2 > newstr_e) {
     733               0 :                                 escape_overflow = TRUE;
     734               0 :                                 break;
     735                 :                         }
     736                 :                         /* copy escaped character */
     737             108 :                         *newstr++ = '\\';
     738             108 :                         *newstr++ = esc;
     739                 :                 } else {
     740          474785 :                         if (newstr + 1 > newstr_e) {
     741               0 :                                 escape_overflow = TRUE;
     742               0 :                                 break;
     743                 :                         }
     744                 :                         /* copy non escaped character */
     745          474785 :                         *newstr++ = *escapestr;
     746                 :                 }
     747                 :         }
     748            3023 :         *newstr = '\0';
     749                 : 
     750            3023 :         if (escape_overflow) {
     751               0 :                 DBG_RETURN((ulong)~0);
     752                 :         }
     753            3023 :         DBG_RETURN((ulong)(newstr - newstr_s));
     754                 : }
     755                 : /* }}} */
     756                 : 
     757                 : /*
     758                 :  * Local variables:
     759                 :  * tab-width: 4
     760                 :  * c-basic-offset: 4
     761                 :  * End:
     762                 :  * vim600: noet sw=4 ts=4 fdm=marker
     763                 :  * vim<600: noet sw=4 ts=4
     764                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:33 +0000 (35 hours ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.