]> mj.ucw.cz Git - libucw.git/blob - charset/setnames.c
Merge with git+ssh://cvs.ucw.cz/projects/sherlock/GIT/sherlock.git#v3.10
[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 /* Names according to RFC 1345 (see http://www.iana.org/assignments/character-sets) */
16
17 static char *cs_names[] = {
18         "US-ASCII",
19         "ISO-8859-1",
20         "ISO-8859-2",
21         "ISO-8859-3",
22         "ISO-8859-4",
23         "ISO-8859-5",
24         "ISO-8859-6",
25         "ISO-8859-7",
26         "ISO-8859-8",
27         "ISO-8859-9",
28         "ISO-8859-10",
29         "ISO-8859-11",
30         "ISO-8859-13",
31         "ISO-8859-14",
32         "ISO-8859-15",
33         "ISO-8859-16",
34         "windows-1250",
35         "windows-1251",
36         "windows-1252",
37         "x-kam-cs",
38         "CSN_369103",
39         "cp852",
40         "x-mac-ce",
41         "x-cork",
42         "utf-8"
43 };
44
45 int
46 find_charset_by_name(char *c)
47 {
48         unsigned int i;
49
50         for(i=0; i<CONV_NUM_CHARSETS; i++)
51                 if (!strcasecmp(cs_names[i], c))
52                         return i;
53         return -1;
54 }
55
56 char *
57 charset_name(int i)
58 {
59   if (i < 0 || i > CONV_NUM_CHARSETS)
60     return "x-unknown";
61   else
62     return cs_names[i];
63 }