prefs: fix a leak.
[metze/wireshark/wip.git] / epan / charsets.h
1 /* charsets.h
2  * Routines for handling character sets
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 #ifndef __CHARSETS_H__
23 #define __CHARSETS_H__
24
25 #include "ws_symbol_export.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 /*
32  * Translation tables that map the upper 128 code points in single-byte
33  * "extended ASCII" character encodings to Unicode code points in the
34  * Basic Multilingual Plane.
35  */
36
37 /* Table for windows-1250 */
38 extern const gunichar2 charset_table_cp1250[0x80];
39
40 /* Tables for ISO-8859-X */
41 extern const gunichar2 charset_table_iso_8859_2[0x80];
42 extern const gunichar2 charset_table_iso_8859_3[0x80];
43 extern const gunichar2 charset_table_iso_8859_4[0x80];
44 extern const gunichar2 charset_table_iso_8859_5[0x80];
45 extern const gunichar2 charset_table_iso_8859_6[0x80];
46 extern const gunichar2 charset_table_iso_8859_7[0x80];
47 extern const gunichar2 charset_table_iso_8859_8[0x80];
48 extern const gunichar2 charset_table_iso_8859_9[0x80];
49 extern const gunichar2 charset_table_iso_8859_10[0x80];
50 extern const gunichar2 charset_table_iso_8859_11[0x80];
51 extern const gunichar2 charset_table_iso_8859_13[0x80];
52 extern const gunichar2 charset_table_iso_8859_14[0x80];
53 extern const gunichar2 charset_table_iso_8859_15[0x80];
54 extern const gunichar2 charset_table_iso_8859_16[0x80];
55
56 /* Tables for Mac character sets */
57 extern const gunichar2 charset_table_mac_roman[0x80];
58
59 /* Tables for DOS code pages */
60 extern const gunichar2 charset_table_cp437[0x80];
61
62 /*
63  * Given a wmem scope, a pointer, and a length, treat the string of bytes
64  * referred to by the pointer and length as an ASCII string, with all bytes
65  * with the high-order bit set being invalid, and return a pointer to a
66  * UTF-8 string, allocated using the wmem scope.
67  *
68  * Octets with the highest bit set will be converted to the Unicode
69  * REPLACEMENT CHARACTER.
70  */
71 WS_DLL_PUBLIC guint8 *
72 get_ascii_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
73
74 WS_DLL_PUBLIC guint8 *
75 get_8859_1_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
76
77 WS_DLL_PUBLIC guint8 *
78 get_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const gunichar2 table[0x80]);
79
80 WS_DLL_PUBLIC guint8 *
81 get_ucs_2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
82
83 WS_DLL_PUBLIC guint8 *
84 get_utf_16_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
85
86 WS_DLL_PUBLIC guint8 *
87 get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
88
89 WS_DLL_PUBLIC guint8 *
90 get_ts_23_038_7bits_string(wmem_allocator_t *scope, const guint8 *ptr,
91         const gint bit_offset, gint no_of_chars);
92
93 WS_DLL_PUBLIC guint8 *
94 get_ascii_7bits_string(wmem_allocator_t *scope, const guint8 *ptr,
95         const gint bit_offset, gint no_of_chars);
96
97 WS_DLL_PUBLIC guint8 *
98 get_ebcdic_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
99
100 #if 0
101 void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
102 guint8 ASCII_to_EBCDIC1(guint8 c);
103 #endif
104 WS_DLL_PUBLIC
105 void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
106 WS_DLL_PUBLIC
107 guint8 EBCDIC_to_ASCII1(guint8 c);
108
109 #ifdef __cplusplus
110 }
111 #endif /* __cplusplus */
112
113 #endif /* __CHARSETS_H__ */
114
115 /*
116  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
117  *
118  * Local variables:
119  * c-basic-offset: 4
120  * tab-width: 8
121  * indent-tabs-mode: nil
122  * End:
123  *
124  * vi: set shiftwidth=4 tabstop=8 expandtab:
125  * :indentSize=4:tabSize=8:noTabs=true:
126  */