]> mj.ucw.cz Git - libucw.git/blob - charset/setnames.c
5aeca021bf8f9c2ebdd069ca2c0835dafd2dcc3a
[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         "ISO-8859-3",
20         "ISO-8859-4",
21         "ISO-8859-5",
22         "ISO-8859-6",
23         "ISO-8859-7",
24         "ISO-8859-8",
25         "ISO-8859-9",
26         "ISO-8859-10",
27         "ISO-8859-11",
28         "ISO-8859-13",
29         "ISO-8859-14",
30         "ISO-8859-15",
31         "ISO-8859-16",
32         "windows-1250",
33         "windows-1252",
34         "x-kam-cs",
35         "CSN_369103",
36         "cp852",
37         "x-mac-ce",
38         "x-cork",
39         "utf-8"
40 };
41
42 int
43 find_charset_by_name(char *c)
44 {
45         unsigned int i;
46
47         for(i=0; i<CONV_NUM_CHARSETS; i++)
48                 if (!strcasecmp(cs_names[i], c))
49                         return i;
50         return -1;
51 }
52
53 char *
54 charset_name(int i)
55 {
56   if (i < 0 || i > CONV_NUM_CHARSETS)
57     return "x-unknown";
58   else
59     return cs_names[i];
60 }