]> mj.ucw.cz Git - libucw.git/blob - charset/setnames.c
Merge with git+ssh://cvs.ucw.cz/projects/sherlock/GIT/sherlock.git#v3.8
[libucw.git] / charset / setnames.c
1 /*
2  *      Character Set Conversion Library 1.0 -- Character Set Names
3  *
4  *      (c) 1998--2005 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-1251",
34         "windows-1252",
35         "x-kam-cs",
36         "CSN_369103",
37         "cp852",
38         "x-mac-ce",
39         "x-cork",
40         "utf-8"
41 };
42
43 int
44 find_charset_by_name(char *c)
45 {
46         unsigned int i;
47
48         for(i=0; i<CONV_NUM_CHARSETS; i++)
49                 if (!strcasecmp(cs_names[i], c))
50                         return i;
51         return -1;
52 }
53
54 char *
55 charset_name(int i)
56 {
57   if (i < 0 || i > CONV_NUM_CHARSETS)
58     return "x-unknown";
59   else
60     return cs_names[i];
61 }