]> mj.ucw.cz Git - libucw.git/blob - charset/setnames.c
e9665971f9422614c2b5707bb727c866c18f06ba
[libucw.git] / charset / setnames.c
1 /*
2  *      Character Set Conversion Library 1.0 -- Character Set Names
3  *
4  *      (c) 1998 Martin Mares <mj@atrey.karlin.mff.cuni.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 char *cs_names[] = {
16         "US-ASCII",
17         "ISO-8859-1",
18         "ISO-8859-2",
19         "windows-1250",
20         "x-kam-cs",
21         "CSN_369103",
22         "cp852",
23         "x-mac-ce",
24         "utf-8"
25 };
26
27 int
28 find_charset_by_name(char *c)
29 {
30         unsigned int i;
31
32         for(i=0; i<CONV_NUM_CHARSETS; i++)
33                 if (!strcasecmp(cs_names[i], c))
34                         return i;
35         return -1;
36 }
37
38 char *
39 charset_name(int i)
40 {
41   if (i < 0 || i > CONV_NUM_CHARSETS)
42     return "x-unknown";
43   else
44     return cs_names[i];
45 }