2 * xenc.c - translate our internal character set codes to and from
3 * X11 character encoding names.
16 * Officially registered encoding names. This list is derived
17 * from the font encodings section of
19 * http://ftp.x.org/pub/DOCS/registry
21 * Where multiple encoding names map to the same encoding id
22 * (such as iso8859-15 and fcd8859-15), the first is considered
23 * canonical and will be returned when translating the id to a
26 { "iso8859-1", CS_ISO8859_1 },
27 { "iso8859-2", CS_ISO8859_2 },
28 { "iso8859-3", CS_ISO8859_3 },
29 { "iso8859-4", CS_ISO8859_4 },
30 { "iso8859-5", CS_ISO8859_5 },
31 { "iso8859-6", CS_ISO8859_6 },
32 { "iso8859-7", CS_ISO8859_7 },
33 { "iso8859-8", CS_ISO8859_8 },
34 { "iso8859-9", CS_ISO8859_9 },
35 { "iso8859-10", CS_ISO8859_10 },
36 { "iso8859-13", CS_ISO8859_13 },
37 { "iso8859-14", CS_ISO8859_14 },
38 { "iso8859-15", CS_ISO8859_15 },
39 { "fcd8859-15", CS_ISO8859_15 },
40 { "hp-roman8", CS_HP_ROMAN8 },
41 { "koi8-r", CS_KOI8_R },
43 * Unofficial encoding names found in the wild.
45 { "iso8859-16", CS_ISO8859_16 },
46 { "koi8-u", CS_KOI8_U },
47 { "ibm-cp437", CS_CP437 },
48 { "ibm-cp850", CS_CP850 },
49 { "ibm-cp866", CS_CP866 },
50 { "microsoft-cp1250", CS_CP1250 },
51 { "microsoft-cp1251", CS_CP1251 },
52 { "microsoft-cp1252", CS_CP1252 },
53 { "microsoft-cp1253", CS_CP1253 },
54 { "microsoft-cp1254", CS_CP1254 },
55 { "microsoft-cp1255", CS_CP1255 },
56 { "microsoft-cp1256", CS_CP1256 },
57 { "microsoft-cp1257", CS_CP1257 },
58 { "microsoft-cp1258", CS_CP1258 },
59 { "mac-roman", CS_MAC_ROMAN },
60 { "viscii1.1-1", CS_VISCII },
61 { "viscii1-1", CS_VISCII },
64 const char *charset_to_xenc(int charset)
68 for (i = 0; i < (int)lenof(xencs); i++)
69 if (charset == xencs[i].charset)
72 return NULL; /* not found */
75 int charset_from_xenc(const char *name)
79 for (i = 0; i < (int)lenof(xencs); i++) {
84 if (tolower(*p) != tolower(*q))
89 return xencs[i].charset;
92 return CS_NONE; /* not found */