Drizzled Public API Documentation

charset.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 /*
00021   Header File that defines all the charset declarations being used in Drizzle source code
00022 */
00023 
00024 #pragma once
00025 
00026 #include <sys/types.h>
00027 #include <cstddef>
00028 
00029 #include <drizzled/visibility.h>
00030 #include <drizzled/common_fwd.h>
00031 #include <drizzled/definitions.h>
00032 
00033 namespace drizzled {
00034 
00035 #define MY_CS_NAME_SIZE     32
00036 #define MY_CS_CTYPE_TABLE_SIZE    257
00037 #define MY_CS_TO_LOWER_TABLE_SIZE 256
00038 #define MY_CS_TO_UPPER_TABLE_SIZE 256
00039 #define MY_CS_SORT_ORDER_TABLE_SIZE 256
00040 #define MY_CS_TO_UNI_TABLE_SIZE   256
00041 #define CHARSET_DIR "charsets/"
00042 #define my_wc_t unsigned long
00043 /* wm_wc and wc_mb return codes */
00044 #define MY_CS_ILSEQ 0     /* Wrong by sequence: wb_wc                   */
00045 #define MY_CS_ILUNI 0     /* Cannot encode Unicode to charset: wc_mb    */
00046 #define MY_CS_TOOSMALL  -101  /* Need at least one byte:    wc_mb and mb_wc */
00047 #define MY_CS_TOOSMALL2 -102  /* Need at least two bytes:   wc_mb and mb_wc */
00048 #define MY_CS_TOOSMALL3 -103  /* Need at least three bytes: wc_mb and mb_wc */
00049 /* These following three are currently not really used */
00050 #define MY_CS_TOOSMALL4 -104  /* Need at least 4 bytes: wc_mb and mb_wc */
00051 #define MY_CS_TOOSMALL5 -105  /* Need at least 5 bytes: wc_mb and mb_wc */
00052 #define MY_CS_TOOSMALL6 -106  /* Need at least 6 bytes: wc_mb and mb_wc */
00053 #define MY_SEQ_INTTAIL  1
00054 #define MY_SEQ_SPACES 2
00055 #define MY_CS_COMPILED  1      /* compiled-in sets               */
00056 #define MY_CS_CONFIG    2      /* sets that have a *.conf file   */
00057 #define MY_CS_INDEX     4      /* sets listed in the Index file  */
00058 #define MY_CS_LOADED    8      /* sets that are currently loaded */
00059 #define MY_CS_BINSORT 16     /* if binary sort order           */
00060 #define MY_CS_PRIMARY 32     /* if primary collation           */
00061 #define MY_CS_STRNXFRM  64     /* if strnxfrm is used for sort   */
00062 #define MY_CS_UNICODE 128    /* is a charset is full unicode   */
00063 #define MY_CS_READY 256    /* if a charset is initialized    */
00064 #define MY_CS_AVAILABLE 512    /* If either compiled-in or loaded*/
00065 #define MY_CS_CSSORT  1024   /* if case sensitive sort order   */
00066 #define MY_CS_HIDDEN  2048   /* don't display in SHOW          */
00067 #define MY_CS_NONASCII  8192   /* if not ASCII-compatible        */
00068 #define MY_CHARSET_UNDEFINED 0
00069 /* Flags for strxfrm */
00070 #define MY_STRXFRM_LEVEL1          0x00000001 /* for primary weights   */
00071 #define MY_STRXFRM_LEVEL2          0x00000002 /* for secondary weights */
00072 #define MY_STRXFRM_LEVEL3          0x00000004 /* for tertiary weights  */
00073 #define MY_STRXFRM_LEVEL4          0x00000008 /* fourth level weights  */
00074 #define MY_STRXFRM_LEVEL5          0x00000010 /* fifth level weights   */
00075 #define MY_STRXFRM_LEVEL6          0x00000020 /* sixth level weights   */
00076 #define MY_STRXFRM_LEVEL_ALL       0x0000003F /* Bit OR for the above six */
00077 #define MY_STRXFRM_NLEVELS         6          /* Number of possible levels*/
00078 #define MY_STRXFRM_PAD_WITH_SPACE  0x00000040 /* if pad result with spaces */
00079 #define MY_STRXFRM_UNUSED_00000080 0x00000080 /* for future extensions     */
00080 #define MY_STRXFRM_DESC_LEVEL1     0x00000100 /* if desc order for level1 */
00081 #define MY_STRXFRM_DESC_LEVEL2     0x00000200 /* if desc order for level2 */
00082 #define MY_STRXFRM_DESC_LEVEL3     0x00000300 /* if desc order for level3 */
00083 #define MY_STRXFRM_DESC_LEVEL4     0x00000800 /* if desc order for level4 */
00084 #define MY_STRXFRM_DESC_LEVEL5     0x00001000 /* if desc order for level5 */
00085 #define MY_STRXFRM_DESC_LEVEL6     0x00002000 /* if desc order for level6 */
00086 #define MY_STRXFRM_DESC_SHIFT      8
00087 #define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions     */
00088 #define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions     */
00089 #define MY_STRXFRM_REVERSE_LEVEL1  0x00010000 /* if reverse order for level1 */
00090 #define MY_STRXFRM_REVERSE_LEVEL2  0x00020000 /* if reverse order for level2 */
00091 #define MY_STRXFRM_REVERSE_LEVEL3  0x00040000 /* if reverse order for level3 */
00092 #define MY_STRXFRM_REVERSE_LEVEL4  0x00080000 /* if reverse order for level4 */
00093 #define MY_STRXFRM_REVERSE_LEVEL5  0x00100000 /* if reverse order for level5 */
00094 #define MY_STRXFRM_REVERSE_LEVEL6  0x00200000 /* if reverse order for level6 */
00095 #define MY_STRXFRM_REVERSE_SHIFT   16
00096 #define ILLEGAL_CHARSET_INFO_NUMBER (UINT32_MAX)
00097 #define MY_UTF8MB4                 "utf8"
00098 #define my_charset_utf8_general_ci ::drizzled::my_charset_utf8mb4_general_ci
00099 #define my_charset_utf8_bin        ::drizzled::my_charset_utf8mb4_bin
00100 #define _MY_U 01  /* Upper case */
00101 #define _MY_L 02  /* Lower case */
00102 #define _MY_NMR 04  /* Numeral (digit) */
00103 #define _MY_SPC 010 /* Spacing character */
00104 #define _MY_PNT 020 /* Punctuation */
00105 #define _MY_CTR 040 /* Control character */
00106 #define _MY_B 0100  /* Blank */
00107 #define _MY_X 0200  /* heXadecimal digit */
00108 
00109 /* Some typedef to make it easy for C++ to make function pointers */
00110 typedef int (*my_charset_conv_mb_wc)(const charset_info_st*, my_wc_t *, const unsigned char*, const unsigned char *);
00111 typedef int (*my_charset_conv_wc_mb)(const charset_info_st*, my_wc_t, unsigned char*, unsigned char *);
00112 typedef size_t (*my_charset_conv_case)(const charset_info_st*, char*, size_t, char*, size_t);
00113 
00114 struct MY_UNICASE_INFO
00115 {
00116   uint16_t toupper;
00117   uint16_t tolower;
00118   uint16_t sort;
00119 };
00120 
00121 struct MY_UNI_CTYPE
00122 {
00123   unsigned char pctype;
00124   unsigned char* ctype;
00125 };
00126 
00127 struct MY_UNI_IDX
00128 {
00129   uint16_t from;
00130   uint16_t to;
00131   unsigned char  *tab;
00132 };
00133 
00134 struct my_match_t
00135 {
00136   uint32_t beg;
00137   uint32_t end;
00138   uint32_t mb_len;
00139 };
00140 
00141 enum my_lex_states
00142 {
00143   MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT,
00144   MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
00145   MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
00146   MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
00147   MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
00148   MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE,
00149   MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON,
00150   MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP,
00151   MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
00152   MY_LEX_IDENT_OR_KEYWORD,
00153   MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN,
00154   MY_LEX_STRING_OR_DELIMITER
00155 };
00156 
00157 /* See strings/charset_info_st.txt for information about this structure  */
00158 struct MY_COLLATION_HANDLER
00159 {
00160   bool (*init)(charset_info_st&, unsigned char *(*alloc)(size_t));
00161   /* Collation routines */
00162   int (*strnncoll)(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool);
00163   int (*strnncollsp)(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool diff_if_only_endspace_difference);
00164   size_t (*strnxfrm)(const charset_info_st*, unsigned char *dst, size_t dstlen, uint32_t nweights, const unsigned char *src, size_t srclen, uint32_t flags);
00165   size_t (*strnxfrmlen)(const charset_info_st*, size_t);
00166   bool (*like_range)(const charset_info_st*, const char *s, size_t s_length, char escape, char w_one, char w_many, 
00167     size_t res_length, char *min_str, char *max_str, size_t *min_len, size_t *max_len);
00168   int (*wildcmp)(const charset_info_st*, const char *str,const char *str_end, const char *wildstr, const char *wildend, int escape,int w_one, int w_many);
00169 
00170   int (*strcasecmp)(const charset_info_st*, const char*, const char *);
00171 
00172   uint32_t (*instr)(const charset_info_st*, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, uint32_t nmatch);
00173 
00174   /* Hash calculation */
00175   void (*hash_sort)(const charset_info_st*, const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
00176   bool (*propagate)();
00177 };
00178 
00179 /* See strings/charset_info_st.txt about information on this structure  */
00180 struct MY_CHARSET_HANDLER
00181 {
00182   /* Multibyte routines */
00183   uint32_t (*ismbchar)(const charset_info_st*, const char*, const char *);
00184   uint32_t (*mbcharlen)(const charset_info_st*, uint32_t c);
00185   size_t (*numchars)(const charset_info_st*, const char *b, const char *e);
00186   size_t (*charpos)(const charset_info_st*, const char *b, const char *e, size_t pos);
00187   size_t (*well_formed_len)(const charset_info_st&, str_ref, size_t nchars, int *error);
00188   size_t (*lengthsp)(const charset_info_st*, const char *ptr, size_t length);
00189   size_t (*numcells)(const charset_info_st*, const char *b, const char *e);
00190 
00191   /* Unicode conversion */
00192   my_charset_conv_mb_wc mb_wc;
00193   my_charset_conv_wc_mb wc_mb;
00194 
00195   /* CTYPE scanner */
00196   int (*ctype)(const charset_info_st *cs, int *ctype, const unsigned char *s, const unsigned char *e);
00197 
00198   /* Functions for case and sort conversion */
00199   size_t (*caseup_str)(const charset_info_st*, char *);
00200   size_t (*casedn_str)(const charset_info_st*, char *);
00201 
00202   my_charset_conv_case caseup;
00203   my_charset_conv_case casedn;
00204 
00205   /* Charset dependant snprintf() */
00206   size_t (*snprintf)(const charset_info_st*, char *to, size_t n, const char *fmt, ...)
00207 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
00208                          __attribute__((format(printf, 4, 5)))
00209 #endif
00210                          ;
00211   size_t (*long10_to_str)(const charset_info_st*, char *to, size_t n, int radix, long int val);
00212   size_t (*int64_t10_to_str)(const charset_info_st*, char *to, size_t n, int radix, int64_t val);
00213 
00214   void (*fill)(const charset_info_st*, char *to, size_t len, int fill);
00215 
00216   /* String-to-number conversion routines */
00217   long (*strntol)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00218   unsigned long (*strntoul)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00219   int64_t (*strntoll)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00220   uint64_t (*strntoull)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00221   double (*strntod)(const charset_info_st*, char *s, size_t l, char **e, int *err);
00222   int64_t (*strtoll10)(const charset_info_st*, const char *nptr, char **endptr, int *error);
00223   uint64_t (*strntoull10rnd)(const charset_info_st*, const char *str, size_t length, int unsigned_fl, char **endptr, int *error);
00224   size_t (*scan)(const charset_info_st*, const char *b, const char *e, int sq);
00225 };
00226 
00227 /* See strings/charset_info_st.txt about information on this structure  */
00228 struct charset_info_st
00229 {
00230   uint32_t      number;
00231   uint32_t      primary_number;
00232   uint32_t      binary_number;
00233   uint32_t      state;
00234   const char *csname;
00235   const char *name;
00236   const char *comment;
00237   const char *tailoring;
00238   unsigned char    *ctype;
00239   unsigned char    *to_lower;
00240   unsigned char    *to_upper;
00241   unsigned char    *sort_order;
00242   uint16_t   *contractions;
00243   uint16_t   **sort_order_big;
00244   uint16_t      *tab_to_uni;
00245   MY_UNI_IDX  *tab_from_uni;
00246   MY_UNICASE_INFO **caseinfo;
00247   unsigned char     *state_map;
00248   unsigned char     *ident_map;
00249   uint32_t      strxfrm_multiply;
00250   unsigned char     caseup_multiply;
00251   unsigned char     casedn_multiply;
00252   uint32_t      mbminlen;
00253   uint32_t      mbmaxlen;
00254   uint16_t    min_sort_char;
00255   uint16_t    max_sort_char; /* For LIKE optimization */
00256   unsigned char     pad_char;
00257   unsigned char     levels_for_compare;
00258   unsigned char     levels_for_order;
00259 
00260   MY_CHARSET_HANDLER *cset;
00261   MY_COLLATION_HANDLER *coll;
00262 
00263   bool isalpha(unsigned char c) const
00264   {
00265     return ctype[c + 1] & (_MY_U | _MY_L);
00266   }
00267 
00268   bool isupper(unsigned char c) const
00269   {
00270     return ctype[c + 1] & _MY_U;
00271   }
00272 
00273   bool islower(unsigned char c) const
00274   {
00275     return ctype[c + 1] & _MY_L;
00276   }
00277 
00278   bool isdigit(unsigned char c) const
00279   {
00280     return ctype[c + 1] & _MY_NMR;
00281   }
00282 
00283   bool isxdigit(unsigned char c) const
00284   {
00285     return ctype[c + 1] & _MY_X;
00286   }
00287 
00288   bool isalnum(unsigned char c) const
00289   {
00290     return ctype[c + 1] & (_MY_U | _MY_L | _MY_NMR);
00291   }
00292 
00293   bool isspace(unsigned char c) const
00294   {
00295     return ctype[c + 1] & _MY_SPC;
00296   }
00297 
00298   bool ispunct(unsigned char c) const  
00299   {
00300     return ctype[c + 1] & _MY_PNT;
00301   }
00302 
00303   bool isprint(unsigned char c) const
00304   {
00305     return ctype[c + 1] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B);
00306   }
00307 
00308   bool isgraph(unsigned char c) const
00309   {
00310     return ctype[c + 1] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR);
00311   }
00312 
00313   bool iscntrl(unsigned char c) const
00314   {
00315     return ctype[c + 1] & _MY_CTR;
00316   }
00317 
00318   bool isvar(char c) const
00319   {
00320     return isalnum(c) || (c) == '_';
00321   }
00322 
00323   char toupper(unsigned char c) const
00324   {
00325     return to_upper[c];
00326   }
00327 
00328   char tolower(unsigned char c) const
00329   {
00330     return to_lower[c];
00331   }
00332 
00333   bool binary_compare() const
00334   {
00335     return state  & MY_CS_BINSORT;
00336   }
00337 
00338   bool use_strnxfrm() const
00339   {
00340     return state & MY_CS_STRNXFRM;
00341   }
00342 
00343   size_t strnxfrm(unsigned char *dst, const size_t dstlen, const unsigned char *src, const uint32_t srclen) const
00344   {
00345     return coll->strnxfrm(this, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE);
00346   }
00347 
00348   int strcasecmp(const char *s, const char *t) const
00349   {
00350     return coll->strcasecmp(this, s, t);
00351   }
00352 
00353   size_t caseup_str(char* src) const
00354   {
00355     return cset->caseup_str(this, src);
00356   }
00357 
00358   size_t casedn_str(char* src) const
00359   {
00360     return cset->casedn_str(this, src);
00361   }
00362 };
00363 
00364 extern DRIZZLED_API charset_info_st *all_charsets[256];
00365 uint32_t get_charset_number(const char *cs_name, uint32_t cs_flags);
00366 uint32_t get_collation_number(const char *name);
00367 const char *get_charset_name(uint32_t cs_number);
00368 void free_charsets();
00369 bool my_charset_same(const charset_info_st*, const charset_info_st*);
00370 size_t escape_string_for_drizzle(const charset_info_st *charset_info, char *to, size_t to_length, const char *from, size_t length);
00371 size_t escape_quotes_for_drizzle(const charset_info_st *charset_info, char *to, size_t to_length, const char *from, size_t length);
00372 extern DRIZZLED_API const charset_info_st *default_charset_info;
00373 extern DRIZZLED_API const charset_info_st *system_charset_info;
00374 extern const charset_info_st *files_charset_info;
00375 extern const charset_info_st *table_alias_charset;
00376 extern MY_UNICASE_INFO *my_unicase_default[256];
00377 extern MY_UNICASE_INFO *my_unicase_turkish[256];
00378 extern MY_UNI_CTYPE my_uni_ctype[256];
00379 extern DRIZZLED_API charset_info_st my_charset_bin;
00380 extern DRIZZLED_API charset_info_st my_charset_utf8mb4_bin;
00381 extern DRIZZLED_API charset_info_st my_charset_utf8mb4_general_ci;
00382 extern DRIZZLED_API charset_info_st my_charset_utf8mb4_unicode_ci;
00383 size_t my_strnxfrmlen_simple(const charset_info_st*, size_t);
00384 int my_strnncollsp_simple(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool diff_if_only_endspace_difference);
00385 size_t my_lengthsp_8bit(const charset_info_st*, const char *ptr, size_t length);
00386 uint32_t my_instr_simple(const charset_info_st*, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, uint32_t nmatch);
00387 int my_strcasecmp_mb(const charset_info_st*, const char *s, const char *t);
00388 
00389 DRIZZLED_API const charset_info_st *get_charset(uint32_t cs_number);
00390 DRIZZLED_API const charset_info_st *get_charset_by_name(const char *cs_name);
00391 DRIZZLED_API const charset_info_st *get_charset_by_csname(const char *cs_name, uint32_t cs_flags);
00392 
00393 /* Functions for 8bit */
00394 int my_mb_ctype_8bit(const charset_info_st*, int*, const unsigned char*, const unsigned char *);
00395 int my_mb_ctype_mb(const charset_info_st*, int*, const unsigned char*, const unsigned char *);
00396 
00397 size_t my_scan_8bit(const charset_info_st*, const char *b, const char *e, int sq);
00398 size_t my_snprintf_8bit(const charset_info_st*, char *to, size_t n, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
00399 
00400 long my_strntol_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00401 unsigned long my_strntoul_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00402 int64_t my_strntoll_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00403 uint64_t my_strntoull_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
00404 double my_strntod_8bit(const charset_info_st*, char *s, size_t l,char **e, int *err);
00405 size_t my_long10_to_str_8bit(const charset_info_st*, char *to, size_t l, int radix, long int val);
00406 size_t my_int64_t10_to_str_8bit(const charset_info_st*, char *to, size_t l, int radix, int64_t val);
00407 int64_t my_strtoll10_8bit(const charset_info_st*, const char *nptr, char **endptr, int *error);
00408 
00409 uint64_t my_strntoull10rnd_8bit(const charset_info_st*, const char *str, size_t length, int unsigned_fl, char **endptr, int *error);
00410 
00411 void my_fill_8bit(const charset_info_st*, char* to, size_t l, int fill);
00412 
00413 bool  my_like_range_simple(const charset_info_st*,
00414             const char *ptr, size_t ptr_length,
00415             char escape, char w_one, char w_many,
00416             size_t res_length,
00417             char *min_str, char *max_str,
00418             size_t *min_length, size_t *max_length);
00419 
00420 bool  my_like_range_mb(const charset_info_st*,
00421         const char *ptr, size_t ptr_length,
00422         char escape, char w_one, char w_many,
00423         size_t res_length,
00424         char *min_str, char *max_str,
00425         size_t *min_length, size_t *max_length);
00426 
00427 int my_wildcmp_8bit(const charset_info_st*,
00428         const char *str,const char *str_end,
00429         const char *wildstr,const char *wildend,
00430         int escape, int w_one, int w_many);
00431 
00432 int my_wildcmp_bin(const charset_info_st*,
00433        const char *str,const char *str_end,
00434        const char *wildstr,const char *wildend,
00435        int escape, int w_one, int w_many);
00436 
00437 size_t my_numchars_8bit(const charset_info_st*, const char *b, const char *e);
00438 size_t my_numcells_8bit(const charset_info_st*, const char *b, const char *e);
00439 size_t my_charpos_8bit(const charset_info_st*, const char *b, const char *e, size_t pos);
00440 size_t my_well_formed_len_8bit(const charset_info_st&, str_ref, size_t pos, int *error);
00441 typedef unsigned char *(*cs_alloc_func)(size_t);
00442 bool my_coll_init_simple(charset_info_st *cs, cs_alloc_func alloc);
00443 bool my_cset_init_8bit(charset_info_st *cs, cs_alloc_func alloc);
00444 uint32_t my_mbcharlen_8bit(const charset_info_st*, uint32_t c);
00445 
00446 /* Functions for multibyte charsets */
00447 int my_wildcmp_mb(const charset_info_st*,
00448       const char *str,const char *str_end,
00449       const char *wildstr,const char *wildend,
00450       int escape, int w_one, int w_many);
00451 size_t my_numchars_mb(const charset_info_st*, const char *b, const char *e);
00452 size_t my_numcells_mb(const charset_info_st*, const char *b, const char *e);
00453 size_t my_charpos_mb(const charset_info_st*, const char *b, const char *e, size_t pos);
00454 size_t my_well_formed_len_mb(const charset_info_st&, str_ref, size_t pos, int *error);
00455 uint32_t my_instr_mb(const charset_info_st*,
00456                  const char *b, size_t b_length,
00457                  const char *s, size_t s_length,
00458                  my_match_t *match, uint32_t nmatch);
00459 
00460 int my_strnncoll_mb_bin(const charset_info_st*  cs,
00461                         const unsigned char *s, size_t slen,
00462                         const unsigned char *t, size_t tlen,
00463                         bool t_is_prefix);
00464 
00465 int my_strnncollsp_mb_bin(const charset_info_st*,
00466                           const unsigned char *a, size_t a_length,
00467                           const unsigned char *b, size_t b_length,
00468                           bool diff_if_only_endspace_difference);
00469 
00470 int my_wildcmp_mb_bin(const charset_info_st*,
00471                       const char *str,const char *str_end,
00472                       const char *wildstr,const char *wildend,
00473                       int escape, int w_one, int w_many);
00474 
00475 int my_strcasecmp_mb_bin(const charset_info_st*, const char *s, const char *t);
00476 
00477 void my_hash_sort_mb_bin(const charset_info_st*,
00478                          const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
00479 
00480 size_t my_strnxfrm_mb(const charset_info_st*,
00481                       unsigned char *dst, size_t dstlen, uint32_t nweights,
00482                       const unsigned char *src, size_t srclen, uint32_t flags);
00483 
00484 int my_wildcmp_unicode(const charset_info_st*,
00485                        const char *str, const char *str_end,
00486                        const char *wildstr, const char *wildend,
00487                        int escape, int w_one, int w_many,
00488                        MY_UNICASE_INFO **weights);
00489 
00490 bool my_propagate_simple();
00491 bool my_propagate_complex();
00492 
00493 
00494 uint32_t my_strxfrm_flag_normalize(uint32_t flags, uint32_t nlevels);
00495 void my_strxfrm_desc_and_reverse(unsigned char *str, unsigned char *strend,
00496                                  uint32_t flags, uint32_t level);
00497 size_t my_strxfrm_pad_desc_and_reverse(const charset_info_st*,
00498                                        unsigned char *str, unsigned char *frmend, unsigned char *strend,
00499                                        uint32_t nweights, uint32_t flags, uint32_t level);
00500 
00501 bool my_charset_is_ascii_compatible(const charset_info_st*);
00502 
00503 /*
00504   Compare 0-terminated UTF8 strings.
00505 
00506   SYNOPSIS
00507     my_strcasecmp_utf8mb3()
00508     cs                  character set handler
00509     s                   First 0-terminated string to compare
00510     t                   Second 0-terminated string to compare
00511 
00512   IMPLEMENTATION
00513 
00514   RETURN
00515     - negative number if s < t
00516     - positive number if s > t
00517     - 0 is the strings are equal
00518 */
00519 int my_wc_mb_filename(const charset_info_st*, my_wc_t wc, unsigned char *s, unsigned char *e);
00520 int my_mb_wc_filename(const charset_info_st*, my_wc_t *pwc, const unsigned char *s, const unsigned char *e);
00521 
00522 int my_strnncoll_8bit_bin(const charset_info_st*,
00523                           const unsigned char *s, size_t slen,
00524                           const unsigned char *t, size_t tlen,
00525                           bool t_is_prefix);
00526 int my_strnncollsp_8bit_bin(const charset_info_st*,
00527                             const unsigned char *a, size_t a_length,
00528                             const unsigned char *b, size_t b_length,
00529                             bool diff_if_only_endspace_difference);
00530 size_t my_case_str_bin(const charset_info_st*, char *);
00531 size_t my_case_bin(const charset_info_st*, char*,
00532                    size_t srclen, char*, size_t);
00533 int my_strcasecmp_bin(const charset_info_st*,
00534                       const char *s, const char *t);
00535 size_t my_strnxfrm_8bit_bin(const charset_info_st*,
00536                      unsigned char * dst, size_t dstlen, uint32_t nweights,
00537                      const unsigned char *src, size_t srclen, uint32_t flags);
00538 uint32_t my_instr_bin(const charset_info_st*,
00539                       const char *b, size_t b_length,
00540                       const char *s, size_t s_length,
00541                       my_match_t *match, uint32_t nmatch);
00542 size_t my_lengthsp_binary(const charset_info_st*,
00543                           const char*, size_t length);
00544 int my_mb_wc_bin(const charset_info_st*,
00545                  my_wc_t *wc, const unsigned char *str,
00546                  const unsigned char *end);
00547 int my_wc_mb_bin(const charset_info_st*, my_wc_t wc,
00548                  unsigned char *str, unsigned char *end);
00549 void my_hash_sort_8bit_bin(const charset_info_st*,
00550                            const unsigned char *key, size_t len,
00551                            uint32_t *nr1, uint32_t *nr2);
00552 bool my_coll_init_8bit_bin(charset_info_st *cs,
00553                            cs_alloc_func);
00554 int my_strnncoll_binary(const charset_info_st*,
00555                         const unsigned char *s, size_t slen,
00556                         const unsigned char *t, size_t tlen,
00557                         bool t_is_prefix);
00558 int my_strnncollsp_binary(const charset_info_st*,
00559                           const unsigned char *s, size_t slen,
00560                           const unsigned char *t, size_t tlen,
00561                           bool);
00562 
00563 inline static int my_strnncoll(const charset_info_st *cs, 
00564                                const unsigned char *s, 
00565                                const size_t slen, 
00566                                const unsigned char *t,
00567                                const size_t tlen) 
00568 {
00569   return (cs->coll->strnncoll(cs, s, slen, t, tlen, 0));
00570 }
00571 
00572 inline static bool my_like_range(const charset_info_st *cs,
00573                                  const char *ptr, const size_t ptrlen,
00574                                  const char escape, 
00575                                  const char w_one,
00576                                  const char w_many, 
00577                                  const size_t reslen, 
00578                                  char *minstr, char *maxstr, 
00579                                  size_t *minlen, size_t *maxlen)
00580 {
00581   return (cs->coll->like_range(cs, ptr, ptrlen, escape, w_one, w_many, reslen, 
00582                                minstr, maxstr, minlen, maxlen));
00583 }
00584 
00585 inline static int my_wildcmp(const charset_info_st *cs,
00586                              const char *str, const char *strend,
00587                              const char *w_str, const char *w_strend,
00588                              const int escape,
00589                              const int w_one, const int w_many) 
00590 {
00591   return (cs->coll->wildcmp(cs, str, strend, w_str, w_strend, escape, w_one, w_many));
00592 }
00593 
00594 template <typename CHAR_T>
00595 inline static size_t my_charpos(const charset_info_st *cs, 
00596                                 const CHAR_T *b, const CHAR_T* e, size_t num)
00597 {
00598   return cs->cset->charpos(cs, reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(e), num);
00599 }
00600 
00601 inline static bool use_mb(const charset_info_st *cs)
00602 {
00603   return cs->cset->ismbchar != NULL;
00604 }
00605 
00606 inline static unsigned int  my_ismbchar(const charset_info_st *cs, const char *a, const char *b)
00607 {
00608   return cs->cset->ismbchar(cs, a, b);
00609 }
00610 
00611 inline static unsigned int my_mbcharlen(const charset_info_st *cs, uint32_t c)
00612 {
00613   return cs->cset->mbcharlen(cs, c);
00614 }
00615 
00616 
00617 inline static long my_strntol(const charset_info_st *cs, 
00618                               const char* s, const size_t l, const int base, char **e, int *err)
00619 {
00620   return (cs->cset->strntol(cs, s, l, base, e, err));
00621 }
00622 
00623 inline static unsigned long my_strntoul(const charset_info_st *cs, 
00624                                         const char* s, const size_t l, const int base, 
00625                                         char **e, int *err)
00626 {
00627   return (cs->cset->strntoul(cs, s, l, base, e, err));
00628 }
00629 
00630 inline static int64_t my_strntoll(const charset_info_st *cs, 
00631                                  const char* s, const size_t l, const int base, char **e, int *err)
00632 {
00633   return (cs->cset->strntoll(cs, s, l, base, e, err));
00634 }
00635 
00636 inline static int64_t my_strntoull(const charset_info_st *cs, 
00637                                    const char* s, const size_t l, const int base, 
00638                                    char **e, int *err)
00639 {
00640   return (cs->cset->strntoull(cs, s, l, base, e, err));
00641 }
00642 
00643 
00644 inline static double my_strntod(const charset_info_st *cs, 
00645                                 char* s, const size_t l, char **e, int *err)
00646 {
00647   return (cs->cset->strntod(cs, s, l, e, err));
00648 }
00649 
00650 int make_escape_code(const charset_info_st*, const char *escape);
00651 
00652 } /* namespace drizzled */