2 * Routines to work around deficiencies in Core Foundation, such as the
3 * lack of a routine to convert a CFString to a C string of arbitrary
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 2001 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <CoreFoundation/CoreFoundation.h>
17 #include <wsutil/cfutils.h>
20 * Convert a CFString to a UTF-8-encoded C string; the resulting string
21 * is allocated with g_malloc(). Returns NULL if the conversion fails.
24 CFString_to_C_string(CFStringRef cfstring
)
29 string_len
= CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstring
),
30 kCFStringEncodingUTF8
);
31 string
= (char *)g_malloc(string_len
+ 1);
32 if (!CFStringGetCString(cfstring
, string
, string_len
+ 1,
33 kCFStringEncodingUTF8
)) {
41 * Editor modelines - https://www.wireshark.org/tools/modelines.html
49 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
50 * :indentSize=8:tabSize=8:noTabs=false: