MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_charset.c
1 /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #include <my_global.h>
17 #include <m_ctype.h>
18 #include <my_sys.h>
19 #include <mysql_version.h>
20 
21 #include <stdio.h>
22 
23 static void _print_array(uint8 *data, uint size)
24 {
25  uint i;
26  for (i = 0; i < size; ++i)
27  {
28  if (i == 0 || i % 16 == size % 16) printf(" ");
29  printf(" %02x", data[i]);
30  if ((i+1) % 16 == size % 16) printf("\n");
31  }
32 }
33 
34 static void _print_csinfo(CHARSET_INFO *cs)
35 {
36  printf("%s #%d\n", cs->name, cs->number);
37  printf("ctype:\n"); _print_array(cs->ctype, 257);
38  printf("to_lower:\n"); _print_array(cs->to_lower, 256);
39  printf("to_upper:\n"); _print_array(cs->to_upper, 256);
40  printf("sort_order:\n"); _print_array(cs->sort_order, 256);
41  printf("collate: %3s (%d, %p, %p, %p)\n",
42  cs->strxfrm_multiply ? "yes" : "no",
43  cs->strxfrm_multiply,
44  cs->strnncoll,
45  cs->strnxfrm,
46  cs->like_range);
47  printf("multi-byte: %3s (%d, %p, %p, %p)\n",
48  cs->mbmaxlen > 1 ? "yes" : "no",
49  cs->mbmaxlen,
50  cs->ismbchar,
51  cs->ismbhead,
52  cs->mbcharlen);
53 }
54 
55 
56 int main(int argc, char **argv) {
57  const char *the_set = MYSQL_CHARSET;
58  char *cs_list;
59  int argcnt = 1;
60  CHARSET_INFO *cs;
61 
62  my_init();
63 
64  if (argc > argcnt && argv[argcnt][0] == '-' && argv[argcnt][1] == '#')
65  DBUG_PUSH(argv[argcnt++]+2);
66 
67  if (argc > argcnt)
68  the_set = argv[argcnt++];
69 
70  if (argc > argcnt)
71  charsets_dir = argv[argcnt++];
72 
73  if (!(cs= get_charset_by_name(the_set, MYF(MY_WME))))
74  return 1;
75 
76  puts("CHARSET INFO:");
77  _print_csinfo(cs);
78  fflush(stdout);
79 
80  return 0;
81 }