2 * Routines for handling character sets
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
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.
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.
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.
22 #ifndef __CHARSETS_H__
23 #define __CHARSETS_H__
25 #include "ws_symbol_export.h"
29 #endif /* __cplusplus */
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.
37 /* Table for windows-1250 */
38 extern const gunichar2 charset_table_cp1250[0x80];
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];
56 /* Tables for Mac character sets */
57 extern const gunichar2 charset_table_mac_roman[0x80];
59 /* Tables for DOS code pages */
60 extern const gunichar2 charset_table_cp437[0x80];
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.
68 * Octets with the highest bit set will be converted to the Unicode
69 * REPLACEMENT CHARACTER.
71 WS_DLL_PUBLIC guint8 *
72 get_ascii_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
74 WS_DLL_PUBLIC guint8 *
75 get_8859_1_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
77 WS_DLL_PUBLIC guint8 *
78 get_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const gunichar2 table[0x80]);
80 WS_DLL_PUBLIC guint8 *
81 get_ucs_2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
83 WS_DLL_PUBLIC guint8 *
84 get_utf_16_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
86 WS_DLL_PUBLIC guint8 *
87 get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const guint encoding);
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);
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);
97 WS_DLL_PUBLIC guint8 *
98 get_ebcdic_string(wmem_allocator_t *scope, const guint8 *ptr, gint length);
101 void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
102 guint8 ASCII_to_EBCDIC1(guint8 c);
105 void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
107 guint8 EBCDIC_to_ASCII1(guint8 c);
111 #endif /* __cplusplus */
113 #endif /* __CHARSETS_H__ */
116 * Editor modelines - http://www.wireshark.org/tools/modelines.html
121 * indent-tabs-mode: nil
124 * vi: set shiftwidth=4 tabstop=8 expandtab:
125 * :indentSize=4:tabSize=8:noTabs=true: