23 #include <my_global.h>
29 uchar to_lower[256], sort_order[256];
31 static int ascii_output=1;
32 static string tab_names[]={
"to_lower[]={",
"to_upper[]={",
"sort_order[]={" };
33 static uchar* tabell[]= {to_lower,to_upper,sort_order};
35 void get_options(),init_case_convert();
43 DBUG_PROCESS (argv[0]);
45 get_options(&argc,&argv);
47 puts(
"Tabells for caseconverts and sorttest of characters\n");
48 for (i=0 ; i < 3 ; i++)
50 printf(
"uchar %s\n",tab_names[i]);
51 for (j=0 ; j <= 255 ; j++)
53 ch=(int) tabell[i][j];
54 if (ascii_output && isprint(ch) && ! (ch & 128))
56 if (strchr(
"\\'",(
char) ch))
57 printf(
"'\\%c', ",ch);
62 printf(
"'\\%03o',",ch);
73 void get_options(argc,argv)
75 register
char **argv[];
81 help=0; ascii_output=1;
82 while (--*argc >0 && *(pos = *(++*argv)) ==
'-' )
99 printf(
"%s Ver 1.0\n",progname);
102 puts(
"Output tabells of to_lower[], to_upper[] and sortorder[]\n");
103 printf(
"Usage: %s [-n?I]\n",progname);
104 puts(
"Options: -? or -I \"Info\" -n \"numeric output\"");
107 fprintf(stderr,
"illegal option: -%c\n",*pos);
119 #ifdef USE_INTERNAL_CTYPE
120 #define MAX_CHAR_OK CHAR_MAX
122 #define MAX_CHAR_OK 127
127 void init_case_convert()
130 reg2 uchar *higher_pos,*lower_pos;
131 DBUG_ENTER(
"init_case_convert");
133 for (i=0 ; i <= MAX_CHAR_OK ; i++)
135 to_upper[
i]= sort_order[
i]= (islower(i) ? toupper(i) : (char) i);
136 to_lower[
i]= (isupper(i) ? tolower(i) : (char) i);
138 #if MAX_CHAR_OK != 255
139 for (i--; i++ < 255 ;)
140 to_upper[i]= sort_order[i]= to_lower[i]= (
char)
i;
144 higher_pos= (uchar *)
"\xd0\xd8\xda\xdb\xdc\xd3";
145 lower_pos= (uchar *)
"\xd4\xcc\xce\xdf\xc9\xd7";
147 #ifdef USE_INTERNAL_CTYPE
148 higher_pos=lower_pos= (uchar* )
"";
150 #if defined(DEC_MULTINATIONAL_CHAR) || defined(HP_MULTINATIONAL_CHAR)
151 higher_pos= (uchar *)
"\305\304\326\311\334";
152 lower_pos= (uchar *)
"\345\344\366\351\374";
154 higher_pos= (uchar *)
"[]\\@^";
155 lower_pos= (uchar *)
"{}|`~";
162 to_upper[ *lower_pos ] = sort_order[ *lower_pos ] = (char) *higher_pos;
163 to_lower[ *higher_pos++ ] = (char) *lower_pos++;
170 higher_pos= lower_pos= (uchar *)
"";
172 #ifdef USE_ISO_8859_1
173 higher_pos= (uchar *)
"\305\304\326\334\311";
174 lower_pos= (uchar *)
"\304\305\326YE";
176 higher_pos= (uchar *)
"][\\~`";
177 lower_pos= (uchar *)
"[\\]YE";
183 sort_order[ *higher_pos ] =
184 sort_order[(uchar)to_lower[*higher_pos]] = *lower_pos;
185 higher_pos++; lower_pos++;