1
/* Copyright (C) 2000 MySQL AB
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.
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.
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
18
Written by Alexander Barkov to check what
19
a charset is in your favorite web browser
22
#include <my_global.h>
25
#include <mysql_version.h>
29
typedef struct char_info_st
39
static int chcmp(const void *vf, const void *vs)
44
return f->srt-s->srt ? f->srt-s->srt : f->uni-s->uni;
47
static void print_cs(CHARSET_INFO *cs)
57
printf("<BODY><PRE>\n");
58
printf("Charset %s\n",cs->name);
61
printf("<TR><TH>Code<TH>Uni<TH>Sort<TH>Ctype<TH>Ch<TH>Lo<TH>Up</TR>");
66
ch[i].srt=cs->sort_order ? cs->sort_order[i] : i;
67
ch[i].uni=cs->tab_to_uni[i];
68
ch[i].low=cs->tab_to_uni[cs->to_lower[i]];
69
ch[i].upp=cs->tab_to_uni[cs->to_upper[i]];
70
ch[i].ctp=cs->ctype[i+1];
73
qsort(ch,256,sizeof(MY_CH),&chcmp);
78
clr = (srt!=ch[i].srt) ? !clr : clr;
80
printf("<TR bgcolor=#%s>",clr ? "DDDDDD" : "EEEE99");
81
printf("<TD>%02X",ch[i].cod);
82
printf("<TD>%04X",ch[i].uni);
83
printf("<TD>%02X",ch[i].srt);
85
printf("<TD>%s%s%s%s%s%s%s%s",
86
ch[i].ctp & _MY_U ? "U" : "",
87
ch[i].ctp & _MY_L ? "L" : "",
88
ch[i].ctp & _MY_NMR ? "N" : "",
89
ch[i].ctp & _MY_SPC ? "S" : "",
90
ch[i].ctp & _MY_PNT ? "P" : "",
91
ch[i].ctp & _MY_CTR ? "C" : "",
92
ch[i].ctp & _MY_B ? "B" : "",
93
ch[i].ctp & _MY_X ? "X" : "");
95
if ((ch[i].uni >= 0x80) && (ch[i].uni <= 0x9F))
98
Control characters 0x0080..0x009F are dysplayed by some
99
browers as if they were letters. Don't print them to
102
printf("<TD>ctrl<TD>ctrl<TD>ctrl");
106
printf("<TD>&#%d;",ch[i].uni);
107
printf("<TD>&#%d;",ch[i].low);
108
printf("<TD>&#%d;",ch[i].upp);
113
printf("</TABLE>\n");
114
printf("</PRE></BODY>\n");
118
static void print_index()
123
get_charset_by_name("",MYF(0)); /* To execute init_available_charsets */
125
printf("All charsets\n");
126
printf("<table border=1>\n");
127
printf("<tr bgcolor=EEEE99><th>ID<th>Charset<th>Collation<th>Def<th>Bin<th>Com<th>Comment\n");
128
for (cs=all_charsets ; cs < all_charsets+256; cs++)
132
printf("<tr bgcolor=#%s><td><a href=\"?%s\">%d</a><td>%s<td>%s<td>%s<td>%s<td>%s<td>%s\n",
133
(clr= !clr) ? "DDDDDD" : "EEEE99",
134
cs[0]->name,cs[0]->number,cs[0]->csname,
136
(cs[0]->state & MY_CS_PRIMARY) ? "def " : " ",
137
(cs[0]->state & MY_CS_BINSORT) ? "bin " : " ",
138
(cs[0]->state & MY_CS_COMPILED) ? "com " : " ",
141
printf("</table>\n");
144
int main(int argc, char **argv) {
145
const char *the_set = NULL;
149
if (getenv("SCRIPT_NAME"))
151
printf("Content-Type: text/html\r\n\r\n");
155
if (argc > argcnt && argv[argcnt][0] == '-' && argv[argcnt][1] == '#')
157
DBUG_PUSH(argv[argcnt++]+2);
161
the_set = argv[argcnt++];
164
charsets_dir = argv[argcnt++];
172
if (!(cs= get_charset_by_name(the_set, MYF(MY_WME))))