~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/test_charset.cc

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 MySQL AB
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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, uint32_t size)
 
24
{
 
25
  uint32_t 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 = DRIZZLE_CHARSET;
 
58
  char *cs_list;
 
59
  int argcnt = 1;
 
60
  CHARSET_INFO *cs;
 
61
 
 
62
  my_init();
 
63
 
 
64
  if (argc > argcnt)
 
65
    the_set = argv[argcnt++];
 
66
 
 
67
  if (argc > argcnt)
 
68
    charsets_dir = argv[argcnt++];
 
69
 
 
70
  if (!(cs= get_charset_by_name(the_set, MYF(MY_WME))))
 
71
    return 1;
 
72
 
 
73
  puts("CHARSET INFO:");
 
74
  _print_csinfo(cs);
 
75
  fflush(stdout);
 
76
 
 
77
#ifdef NOT_USED_ANYMORE
 
78
  cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
 
79
  printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list);
 
80
  free(cs_list);
 
81
 
 
82
  cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED));
 
83
  printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list);
 
84
  free(cs_list);
 
85
#endif
 
86
 
 
87
  return 0;
 
88
}