Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
unicode-utils.h
Go to the documentation of this file.
1 /* unicode-utils.h
2  * Unicode utility definitions
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 2006 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef __UNICODEUTIL_H__
12 #define __UNICODEUTIL_H__
13 
14 #include "ws_symbol_export.h"
15 
16 #include <glib.h>
17 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 WS_DLL_PUBLIC
28 int ws_utf8_char_len(guint8 ch);
29 
30 #ifdef _WIN32
31 
32 #include <windows.h>
33 #include <tchar.h>
34 #include <wchar.h>
35 
43 WS_DLL_PUBLIC
44 const wchar_t * utf_8to16(const char *utf8str);
45 
52 WS_DLL_PUBLIC
53 void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt,
54  ...) G_GNUC_PRINTF(3, 4);
55 
63 WS_DLL_PUBLIC
64 gchar * utf_16to8(const wchar_t *utf16str);
65 
75 WS_DLL_PUBLIC
76 void arg_list_utf_16to8(int argc, char *argv[]);
77 
78 
79 #endif /* _WIN32 */
80 
81 /*
82  * defines for helping with UTF-16 surrogate pairs
83  */
84 
85 #define IS_LEAD_SURROGATE(uchar2) \
86  ((uchar2) >= 0xd800 && (uchar2) < 0xdc00)
87 #define IS_TRAIL_SURROGATE(uchar2) \
88  ((uchar2) >= 0xdc00 && (uchar2) < 0xe000)
89 #define SURROGATE_VALUE(lead, trail) \
90  (((((lead) - 0xd800) << 10) | ((trail) - 0xdc00)) + 0x10000)
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* __UNICODEUTIL_H__ */