Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
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  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 #ifndef __CHARSETS_H__
11 #define __CHARSETS_H__
12 
13 #include "ws_symbol_export.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif /* __cplusplus */
18 
19 /*
20  * Translation tables that map the upper 128 code points in single-byte
21  * "extended ASCII" character encodings to Unicode code points in the
22  * Basic Multilingual Plane.
23  */
24 
25 /* Table for windows-1250 */
26 extern const gunichar2 charset_table_cp1250[0x80];
27 
28 /* Tables for ISO-8859-X */
29 extern const gunichar2 charset_table_iso_8859_2[0x80];
30 extern const gunichar2 charset_table_iso_8859_3[0x80];
31 extern const gunichar2 charset_table_iso_8859_4[0x80];
32 extern const gunichar2 charset_table_iso_8859_5[0x80];
33 extern const gunichar2 charset_table_iso_8859_6[0x80];
34 extern const gunichar2 charset_table_iso_8859_7[0x80];
35 extern const gunichar2 charset_table_iso_8859_8[0x80];
36 extern const gunichar2 charset_table_iso_8859_9[0x80];
37 extern const gunichar2 charset_table_iso_8859_10[0x80];
38 extern const gunichar2 charset_table_iso_8859_11[0x80];
39 extern const gunichar2 charset_table_iso_8859_13[0x80];
40 extern const gunichar2 charset_table_iso_8859_14[0x80];
41 extern const gunichar2 charset_table_iso_8859_15[0x80];
42 extern const gunichar2 charset_table_iso_8859_16[0x80];
43 
44 /* Tables for Mac character sets */
45 extern const gunichar2 charset_table_mac_roman[0x80];
46 
47 /* Tables for DOS code pages */
48 extern const gunichar2 charset_table_cp437[0x80];
49 
50 /* Tables for EBCDIC code pages */
51 extern const gunichar2 charset_table_ebcdic[256];
52 extern const gunichar2 charset_table_ebcdic_cp037[256];
53 
54 /*
55  * Given a wmem scope, a pointer, and a length, treat the string of bytes
56  * referred to by the pointer and length as an ASCII string, with all bytes
57  * with the high-order bit set being invalid, and return a pointer to a
58  * UTF-8 string, allocated using the wmem scope.
59  *
60  * Octets with the highest bit set will be converted to the Unicode
61  * REPLACEMENT CHARACTER.
62  */
63 WS_DLL_PUBLIC guint8 *
64 get_ascii_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
65 
66 WS_DLL_PUBLIC guint8 *
67 get_8859_1_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
68 
69 WS_DLL_PUBLIC guint8 *
70 get_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const gunichar2 table[0x80]);
71 
72 WS_DLL_PUBLIC guint8 *
73 get_ucs_2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
74 
75 WS_DLL_PUBLIC guint8 *
76 get_utf_16_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
77 
78 WS_DLL_PUBLIC guint8 *
79 get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
80 
81 WS_DLL_PUBLIC guint8 *
82 get_ts_23_038_7bits_string(wmem_allocator_t *scope, const guint8 *ptr,
83  const gint bit_offset, gint no_of_chars);
84 
85 WS_DLL_PUBLIC guint8 *
86 get_ascii_7bits_string(wmem_allocator_t *scope, const guint8 *ptr,
87  const gint bit_offset, gint no_of_chars);
88 
89 WS_DLL_PUBLIC guint8 *
90 get_nonascii_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const gunichar2 table[256]);
91 
92 WS_DLL_PUBLIC guint8 *
93 get_t61_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
94 
95 #if 0
96 void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
97 guint8 ASCII_to_EBCDIC1(guint8 c);
98 #endif
99 WS_DLL_PUBLIC
100 void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
101 WS_DLL_PUBLIC
102 guint8 EBCDIC_to_ASCII1(guint8 c);
103 
104 #ifdef __cplusplus
105 }
106 #endif /* __cplusplus */
107 
108 #endif /* __CHARSETS_H__ */
109 
110 /*
111  * Editor modelines - http://www.wireshark.org/tools/modelines.html
112  *
113  * Local variables:
114  * c-basic-offset: 4
115  * tab-width: 8
116  * indent-tabs-mode: nil
117  * End:
118  *
119  * vi: set shiftwidth=4 tabstop=8 expandtab:
120  * :indentSize=4:tabSize=8:noTabs=true:
121  */
Definition: wmem_allocator.h:26