]> mj.ucw.cz Git - libucw.git/blob - charset/setnames.c
b1d43b59b446f46cec0637fcf74b44aaeb1e1c40
[libucw.git] / charset / setnames.c
1 /*
2  *      Character Set Conversion Library 1.0 -- Character Set Names
3  *
4  *      (c) 1998--2001 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU General Public License.
8  */
9
10 #include "lib/lib.h"
11 #include "charset/charconv.h"
12
13 #include <string.h>
14
15 static char *cs_names[] = {
16         "US-ASCII",
17         "ISO-8859-1",
18         "ISO-8859-2",
19         "windows-1250",
20         "windows-1252",
21         "x-kam-cs",
22         "CSN_369103",
23         "cp852",
24         "x-mac-ce",
25         "x-cork",
26         "utf-8"
27 };
28
29 int
30 find_charset_by_name(char *c)
31 {
32         unsigned int i;
33
34         for(i=0; i<CONV_NUM_CHARSETS; i++)
35                 if (!strcasecmp(cs_names[i], c))
36                         return i;
37         return -1;
38 }
39
40 char *
41 charset_name(int i)
42 {
43   if (i < 0 || i > CONV_NUM_CHARSETS)
44     return "x-unknown";
45   else
46     return cs_names[i];
47 }