]> mj.ucw.cz Git - libucw.git/blob - charset/setnames.c
Merge branch 'v3.12.4'
[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  *      (c) 2007 Pavel Charvat <pchar@ucw.cz>
6  *
7  *      This software may be freely distributed and used according to the terms
8  *      of the GNU General Public License.
9  */
10
11 #include "ucw/lib.h"
12 #include "charset/charconv.h"
13
14 #include <string.h>
15
16 /* Names according to RFC 1345 (see http://www.iana.org/assignments/character-sets) */
17
18 static const char *cs_names[] = {
19         "US-ASCII",
20         "ISO-8859-1",
21         "ISO-8859-2",
22         "ISO-8859-3",
23         "ISO-8859-4",
24         "ISO-8859-5",
25         "ISO-8859-6",
26         "ISO-8859-7",
27         "ISO-8859-8",
28         "ISO-8859-9",
29         "ISO-8859-10",
30         "ISO-8859-11",
31         "ISO-8859-13",
32         "ISO-8859-14",
33         "ISO-8859-15",
34         "ISO-8859-16",
35         "windows-1250",
36         "windows-1251",
37         "windows-1252",
38         "x-kam-cs",
39         "CSN_369103",
40         "cp852",
41         "x-mac-ce",
42         "x-cork",
43         "utf-8",
44         "utf-16be",
45         "utf-16le"
46 };
47
48 int
49 find_charset_by_name(const char *c)
50 {
51         unsigned int i;
52
53         for(i=0; i<CONV_NUM_CHARSETS; i++)
54                 if (!strcasecmp(cs_names[i], c))
55                         return i;
56         return -1;
57 }
58
59 char *
60 charset_name(int i)
61 {
62   if (i < 0 || i > CONV_NUM_CHARSETS)
63     return "x-unknown";
64   else
65     return (char *)cs_names[i];
66 }