2 * Unicode utility definitions
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 2006 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __UNICODEUTIL_H__
26 #define __UNICODEUTIL_H__
38 * @file Unicode convenience routines.
41 /** Given a UTF-8 string, convert it to UTF-16. This is meant to be used
42 * to convert between GTK+ 2.x (UTF-8) to Windows (UTF-16).
44 * @param utf8str The string to convert. May be NULL.
45 * @return The string converted to UTF-16. If utf8str is NULL, returns
46 * NULL. The return value should NOT be freed by the caller.
48 wchar_t * utf_8to16(const char *utf8str);
50 /** Create a UTF-16 string (in place) according to the format string.
52 * @param utf16buf The buffer to return the UTF-16 string in.
53 * @param utf16buf_len The size of the 'utf16buf' parameter
54 * @param fmt A standard g_printf() format string
56 void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...);
58 /** Given a UTF-16 string, convert it to UTF-8. This is meant to be used
59 * to convert between GTK+ 2.x (UTF-8) to Windows (UTF-16).
61 * @param utf16str The string to convert. May be NULL.
62 * @return The string converted to UTF-8. If utf16str is NULL, returns
63 * NULL. The return value should NOT be freed by the caller.
65 gchar * utf_16to8(const wchar_t *utf16str);
67 /** Convert the program argument list from UTF-16 to UTF-8 and
68 * store it in the supplied array. This is intended to be used
69 * to normalize command line arguments at program startup.
71 * @param argc The number of arguments. You should simply pass the
72 * first argument from main().
73 * @param argv The argument values (vector). You should simply pass
74 * the second argument from main().
76 void arg_list_utf_16to8(int argc, char *argv[]);
81 #endif /* __UNICODEUTIL_H__ */