Snort: speed up parsing of options by avoiding g_snprintf()
[metze/wireshark/wip.git] / epan / iana_charsets.c
1 /* iana_charsets.c
2  *
3  * Routines and tables for IANA-registered character sets
4  *
5  *    http://www.iana.org/assignments/character-sets/character-sets.xhtml
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * WAP dissector based on original work by Ben Fowler
12  * Updated by Neil Hunter <neil.hunter@energis-squared.com>
13  * WTLS support by Alexandre P. Ferreira (Splice IP)
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28  */
29
30 #include "config.h"
31
32 #include <glib.h>
33
34 #include <epan/proto.h>
35 #include <epan/value_string.h>
36
37 #include <epan/iana_charsets.h>
38
39 /*
40  * Map a MIBenum code for a charset to a Wireshark string encoding.
41  */
42 guint
43 mibenum_charset_to_encoding (guint charset)
44 {
45     switch (charset) {
46         case 3:
47             return ENC_NA|ENC_ASCII;
48
49         case 4:
50             return ENC_NA|ENC_ISO_8859_1;
51
52         case 5:
53             return ENC_NA|ENC_ISO_8859_2;
54
55         case 6:
56             return ENC_NA|ENC_ISO_8859_3;
57
58         case 7:
59             return ENC_NA|ENC_ISO_8859_4;
60
61         case 8:
62             return ENC_NA|ENC_ISO_8859_5;
63
64         case 9:
65             return ENC_NA|ENC_ISO_8859_6;
66
67         case 10:
68             return ENC_NA|ENC_ISO_8859_7;
69
70         case 11:
71             return ENC_NA|ENC_ISO_8859_8;
72
73         case 12:
74             return ENC_NA|ENC_ISO_8859_9;
75
76         case 13:
77             return ENC_NA|ENC_ISO_8859_10;
78
79         case 106:
80             return ENC_NA|ENC_UTF_8;
81
82         case 109:
83             return ENC_NA|ENC_ISO_8859_13;
84
85         case 110:
86             return ENC_NA|ENC_ISO_8859_14;
87
88         case 111:
89             return ENC_NA|ENC_ISO_8859_15;
90
91         case 112:
92             return ENC_NA|ENC_ISO_8859_16;
93
94         case 1000:
95             /*
96              * The IANA page says:
97              *
98              *    this needs to specify network byte order: the
99              *    standard does not specify
100              *
101              * so presumably this means "big-endian UCS-2".
102              */
103             return ENC_BIG_ENDIAN|ENC_UCS_2;
104
105         case 1001:
106             /*
107              * The IANA page says the same thing as for UCS-2.
108              */
109             return ENC_BIG_ENDIAN|ENC_UCS_4;
110
111         case 1013:
112             return ENC_BIG_ENDIAN|ENC_UTF_16;
113
114         case 1014:
115             return ENC_LITTLE_ENDIAN|ENC_UTF_16;
116
117         case 1015:
118             /* XXX - UTF-16 with a BOM at the beginning */
119             return ENC_LITTLE_ENDIAN|ENC_UTF_16;
120
121         case 2011:
122             return ENC_NA|ENC_CP437;
123
124         case 2259:
125             return ENC_NA|ENC_ISO_8859_11;
126
127         default:
128             return ENC_NA|ENC_ASCII;
129     }
130 }
131
132 /* Updated from 10/04/2012 version */
133 static const value_string mibenum_vals_character_sets[] = {
134     {    0, "*" },
135     {    3, "US-ASCII" },
136     {    4, "ISO-8859-1" },
137     {    5, "ISO-8859-2" },
138     {    6, "ISO-8859-3" },
139     {    7, "ISO-8859-4" },
140     {    8, "ISO-8859-5" },
141     {    9, "ISO-8859-6" },
142     {   10, "ISO-8859-7" },
143     {   11, "ISO-8859-8" },
144     {   12, "ISO-8859-9" },
145     {   13, "ISO-8859-10" },
146     {   14, "ISO_6937-2-add" },
147     {   15, "JIS_X0201" },
148     {   16, "JIS_Encoding" },
149     {   17, "Shift_JIS" },
150     {   18, "EUC-JP" },
151     {   19, "Extended_UNIX_Code_Fixed_Width_for_Japanese" },
152     {   20, "BS_4730" },
153     {   21, "SEN_850200_C" },
154     {   22, "IT" },
155     {   23, "ES" },
156     {   24, "DIN_66003" },
157     {   25, "NS_4551-1" },
158     {   26, "NF_Z_62-010" },
159     {   27, "ISO-10646-UTF-1" },
160     {   28, "ISO_646.basic:1983" },
161     {   29, "INVARIANT" },
162     {   30, "ISO_646.irv:1983" },
163     {   31, "NATS-SEFI" },
164     {   32, "NATS-SEFI-ADD" },
165     {   33, "NATS-DANO" },
166     {   34, "NATS-DANO-ADD" },
167     {   35, "SEN_850200_B" },
168     {   36, "KS_C_5601-1987" },
169     {   37, "ISO-2022-KR" },
170     {   38, "EUC-KR" },
171     {   39, "ISO-2022-JP" },
172     {   40, "ISO-2022-JP-2" },
173     {   41, "JIS_C6220-1969-jp" },
174     {   42, "JIS_C6220-1969-ro" },
175     {   43, "PT" },
176     {   44, "greek7-old" },
177     {   45, "latin-greek" },
178     {   46, "NF_Z_62-010_(1973)" },
179     {   47, "Latin-greek-1" },
180     {   48, "ISO_5427" },
181     {   49, "JIS_C6226-1978" },
182     {   50, "BS_viewdata" },
183     {   51, "INIS" },
184     {   52, "INIS-8" },
185     {   53, "INIS-cyrillic" },
186     {   54, "ISO_5427:1981" },
187     {   55, "ISO_5428:1980" },
188     {   56, "GB_1988-80" },
189     {   57, "GB_2312-80" },
190     {   58, "NS_4551-2" },
191     {   59, "videotex-suppl" },
192     {   60, "PT2" },
193     {   61, "ES2" },
194     {   62, "MSZ_7795.3" },
195     {   63, "JIS_C6226-1983" },
196     {   64, "greek7" },
197     {   65, "ASMO_449" },
198     {   66, "iso-ir-90" },
199     {   67, "JIS_C6229-1984-a" },
200     {   68, "JIS_C6229-1984-b" },
201     {   69, "JIS_C6229-1984-b-add" },
202     {   70, "JIS_C6229-1984-hand" },
203     {   71, "JIS_C6229-1984-hand-add" },
204     {   72, "JIS_C6229-1984-kana" },
205     {   73, "ISO_2033-1983" },
206     {   74, "ANSI_X3.110-1983" },
207     {   75, "T.61-7bit" },
208     {   76, "T.61-8bit" },
209     {   77, "ECMA-cyrillic" },
210     {   78, "CSA_Z243.4-1985-1" },
211     {   79, "CSA_Z243.4-1985-2" },
212     {   80, "CSA_Z243.4-1985-gr" },
213     {   81, "ISO-8859-6-E" },
214     {   82, "ISO-8859-6-I" },
215     {   83, "T.101-G2" },
216     {   84, "ISO-8859-8-E" },
217     {   85, "ISO-8859-8-I" },
218     {   86, "CSN_369103" },
219     {   87, "JUS_I.B1.002" },
220     {   88, "IEC_P27-1" },
221     {   89, "JUS_I.B1.003-serb" },
222     {   90, "JUS_I.B1.003-mac" },
223     {   91, "greek-ccitt" },
224     {   92, "NC_NC00-10:81" },
225     {   93, "ISO_6937-2-25" },
226     {   94, "GOST_19768-74" },
227     {   95, "ISO_8859-supp" },
228     {   96, "ISO_10367-box" },
229     {   97, "latin-lap" },
230     {   98, "JIS_X0212-1990" },
231     {   99, "DS_2089" },
232     {  100, "us-dk" },
233     {  101, "dk-us" },
234     {  102, "KSC5636" },
235     {  103, "UNICODE-1-1-UTF-7" },
236     {  104, "ISO-2022-CN" },
237     {  105, "ISO-2022-CN-EXT" },
238     {  106, "UTF-8" },
239     {  109, "ISO-8859-13" },
240     {  110, "ISO-8859-14" },
241     {  111, "ISO-8859-15" },
242     {  112, "ISO-8859-16" },
243     {  113, "GBK" },
244     {  114, "GB18030" },
245     {  115, "OSD_EBCDIC_DF04_15" },
246     {  116, "OSD_EBCDIC_DF03_IRV" },
247     {  117, "OSD_EBCDIC_DF04_1" },
248     {  118, "ISO-11548-1" },
249     {  119, "KZ-1048" },
250
251     { 1000, "ISO-10646-UCS-2" },
252     { 1001, "ISO-10646-UCS-4" },
253     { 1002, "ISO-10646-UCS-Basic" },
254     { 1003, "ISO-10646-Unicode-Latin1" },
255     { 1004, "ISO-10646-J-1" },
256     { 1005, "ISO-Unicode-IBM-1261" },
257     { 1006, "ISO-Unicode-IBM-1268" },
258     { 1007, "ISO-Unicode-IBM-1276" },
259     { 1008, "ISO-Unicode-IBM-1264" },
260     { 1009, "ISO-Unicode-IBM-1265" },
261     { 1010, "UNICODE-1-1" },
262     { 1011, "SCSU" },
263     { 1012, "UTF-7" },
264     { 1013, "UTF-16BE" },
265     { 1014, "UTF-16LE" },
266     { 1015, "UTF-16" },
267     { 1016, "CESU-8" },
268     { 1017, "UTF-32" },
269     { 1018, "UTF-32BE" },
270     { 1019, "UTF-32LE" },
271     { 1020, "BOCU-1" },
272
273     { 2000, "ISO-8859-1-Windows-3.0-Latin-1" },
274     { 2001, "ISO-8859-1-Windows-3.1-Latin-1" },
275     { 2002, "ISO-8859-2-Windows-Latin-2" },
276     { 2003, "ISO-8859-9-Windows-Latin-5" },
277     { 2004, "hp-roman8" },
278     { 2005, "Adobe-Standard-Encoding" },
279     { 2006, "Ventura-US" },
280     { 2007, "Ventura-International" },
281     { 2008, "DEC-MCS" },
282     { 2009, "IBM850" },
283     { 2010, "IBM852" },
284     { 2011, "IBM437" },
285     { 2012, "PC8-Danish-Norwegian" },
286     { 2013, "IBM862" },
287     { 2014, "PC8-Turkish" },
288     { 2015, "IBM-Symbols" },
289     { 2016, "IBM-Thai" },
290     { 2017, "HP-Legal" },
291     { 2018, "HP-Pi-font" },
292     { 2019, "HP-Math8" },
293     { 2020, "Adobe-Symbol-Encoding" },
294     { 2021, "HP-DeskTop" },
295     { 2022, "Ventura-Math" },
296     { 2023, "Microsoft-Publishing" },
297     { 2024, "Windows-31J" },
298     { 2025, "GB2312" },
299     { 2026, "Big5" },
300     { 2027, "macintosh" },
301     { 2028, "IBM037" },
302     { 2029, "IBM038" },
303     { 2030, "IBM273" },
304     { 2031, "IBM274" },
305     { 2032, "IBM275" },
306     { 2033, "IBM277" },
307     { 2034, "IBM278" },
308     { 2035, "IBM280" },
309     { 2036, "IBM281" },
310     { 2037, "IBM284" },
311     { 2038, "IBM285" },
312     { 2039, "IBM290" },
313     { 2040, "IBM297" },
314     { 2041, "IBM420" },
315     { 2042, "IBM423" },
316     { 2043, "IBM424" },
317     { 2044, "IBM500" },
318     { 2045, "IBM851" },
319     { 2046, "IBM855" },
320     { 2047, "IBM857" },
321     { 2048, "IBM860" },
322     { 2049, "IBM861" },
323     { 2050, "IBM863" },
324     { 2051, "IBM864" },
325     { 2052, "IBM865" },
326     { 2053, "IBM868" },
327     { 2054, "IBM869" },
328     { 2055, "IBM870" },
329     { 2056, "IBM871" },
330     { 2057, "IBM880" },
331     { 2058, "IBM891" },
332     { 2059, "IBM903" },
333     { 2060, "IBM904" },
334     { 2061, "IBM905" },
335     { 2062, "IBM918" },
336     { 2063, "IBM1026" },
337     { 2064, "EBCDIC-AT-DE" },
338     { 2065, "EBCDIC-AT-DE-A" },
339     { 2066, "EBCDIC-CA-FR" },
340     { 2067, "EBCDIC-DK-NO" },
341     { 2068, "EBCDIC-DK-NO-A" },
342     { 2069, "EBCDIC-FI-SE" },
343     { 2070, "EBCDIC-FI-SE-A" },
344     { 2071, "EBCDIC-FR" },
345     { 2072, "EBCDIC-IT" },
346     { 2073, "EBCDIC-PT" },
347     { 2074, "EBCDIC-ES" },
348     { 2075, "EBCDIC-ES-A" },
349     { 2076, "EBCDIC-ES-S" },
350     { 2077, "EBCDIC-UK" },
351     { 2078, "EBCDIC-US" },
352     { 2079, "UNKNOWN-8BIT" },
353     { 2080, "MNEMONIC" },
354     { 2081, "MNEM" },
355     { 2082, "VISCII" },
356     { 2083, "VIQR" },
357     { 2084, "KOI8-R" },
358     { 2085, "HZ-GB-2312" },
359     { 2086, "IBM866" },
360     { 2087, "IBM775" },
361     { 2088, "KOI8-U" },
362     { 2089, "IBM00858" },
363     { 2090, "IBM00924" },
364     { 2091, "IBM01140" },
365     { 2092, "IBM01141" },
366     { 2093, "IBM01142" },
367     { 2094, "IBM01143" },
368     { 2095, "IBM01144" },
369     { 2096, "IBM01145" },
370     { 2097, "IBM01146" },
371     { 2098, "IBM01147" },
372     { 2099, "IBM01148" },
373     { 2100, "IBM01149" },
374     { 2101, "Big5-HKSCS" },
375     { 2102, "IBM1047" },
376     { 2103, "PTCP154" },
377     { 2104, "Amiga-1251" },
378     { 2105, "KOI7-switched" },
379     { 2106, "BRF" },
380     { 2107, "TSCII" },
381     { 2108, "CP51932" },
382     { 2109, "windows-874" },
383
384     { 2250, "windows-1250" },
385     { 2251, "windows-1251" },
386     { 2252, "windows-1252" },
387     { 2253, "windows-1253" },
388     { 2254, "windows-1254" },
389     { 2255, "windows-1255" },
390     { 2256, "windows-1256" },
391     { 2257, "windows-1257" },
392     { 2258, "windows-1258" },
393     { 2259, "TIS-620" },
394     { 2260, "CP50220" },
395     { 0, NULL }
396 };
397 value_string_ext mibenum_vals_character_sets_ext = VALUE_STRING_EXT_INIT(mibenum_vals_character_sets);
398
399 /*
400  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
401  *
402  * Local variables:
403  * c-basic-offset: 4
404  * tab-width: 8
405  * indent-tabs-mode: nil
406  * End:
407  *
408  * vi: set shiftwidth=4 tabstop=8 expandtab:
409  * :indentSize=4:tabSize=8:noTabs=true:
410  */