1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * SPDX-License-Identifier: LGPL-2.1-or-later
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
27 #ifndef __G_CONVERT_H__
28 #define __G_CONVERT_H__
30 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31 #error "Only <glib.h> can be included directly."
34 #include <glib/gerror.h>
40 * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character
41 * sets is not supported.
42 * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input;
43 * or the character sequence could not be represented in the target
45 * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason.
46 * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input.
47 * @G_CONVERT_ERROR_BAD_URI: URI is invalid.
48 * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path.
49 * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40
50 * @G_CONVERT_ERROR_EMBEDDED_NUL: An embedded NUL character is present in
51 * conversion output where a NUL-terminated string is expected.
54 * Error codes returned by character set conversion routines.
58 G_CONVERT_ERROR_NO_CONVERSION,
59 G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
60 G_CONVERT_ERROR_FAILED,
61 G_CONVERT_ERROR_PARTIAL_INPUT,
62 G_CONVERT_ERROR_BAD_URI,
63 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH,
64 G_CONVERT_ERROR_NO_MEMORY,
65 G_CONVERT_ERROR_EMBEDDED_NUL
71 * Error domain for character set conversions. Errors in this domain will
72 * be from the #GConvertError enumeration. See #GError for information on
75 #define G_CONVERT_ERROR g_convert_error_quark()
77 GQuark g_convert_error_quark (void);
82 * The GIConv struct wraps an iconv() conversion descriptor. It contains
83 * private data and should only be accessed using the following functions.
85 typedef struct _GIConv *GIConv;
88 GIConv g_iconv_open (const gchar *to_codeset,
89 const gchar *from_codeset);
91 gsize g_iconv (GIConv converter,
95 gsize *outbytes_left);
97 gint g_iconv_close (GIConv converter);
100 GLIB_AVAILABLE_IN_ALL
101 gchar* g_convert (const gchar *str,
103 const gchar *to_codeset,
104 const gchar *from_codeset,
106 gsize *bytes_written,
107 GError **error) G_GNUC_MALLOC;
108 GLIB_AVAILABLE_IN_ALL
109 gchar* g_convert_with_iconv (const gchar *str,
113 gsize *bytes_written,
114 GError **error) G_GNUC_MALLOC;
115 GLIB_AVAILABLE_IN_ALL
116 gchar* g_convert_with_fallback (const gchar *str,
118 const gchar *to_codeset,
119 const gchar *from_codeset,
120 const gchar *fallback,
122 gsize *bytes_written,
123 GError **error) G_GNUC_MALLOC;
126 /* Convert between libc's idea of strings and UTF-8.
128 GLIB_AVAILABLE_IN_ALL
129 gchar* g_locale_to_utf8 (const gchar *opsysstring,
132 gsize *bytes_written,
133 GError **error) G_GNUC_MALLOC;
134 GLIB_AVAILABLE_IN_ALL
135 gchar* g_locale_from_utf8 (const gchar *utf8string,
138 gsize *bytes_written,
139 GError **error) G_GNUC_MALLOC;
141 /* Convert between the operating system (or C runtime)
142 * representation of file names and UTF-8.
144 GLIB_AVAILABLE_IN_ALL
145 gchar* g_filename_to_utf8 (const gchar *opsysstring,
148 gsize *bytes_written,
149 GError **error) G_GNUC_MALLOC;
150 GLIB_AVAILABLE_IN_ALL
151 gchar* g_filename_from_utf8 (const gchar *utf8string,
154 gsize *bytes_written,
155 GError **error) G_GNUC_MALLOC;
157 GLIB_AVAILABLE_IN_ALL
158 gchar *g_filename_from_uri (const gchar *uri,
160 GError **error) G_GNUC_MALLOC;
162 GLIB_AVAILABLE_IN_ALL
163 gchar *g_filename_to_uri (const gchar *filename,
164 const gchar *hostname,
165 GError **error) G_GNUC_MALLOC;
166 GLIB_AVAILABLE_IN_ALL
167 gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
168 GLIB_AVAILABLE_IN_ALL
169 gboolean g_get_filename_charsets (const gchar ***filename_charsets);
171 GLIB_AVAILABLE_IN_ALL
172 gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
174 GLIB_AVAILABLE_IN_ALL
175 gchar **g_uri_list_extract_uris (const gchar *uri_list);
179 #endif /* __G_CONVERT_H__ */