1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 #ifndef __G_CONVERT_H__
26 #define __G_CONVERT_H__
28 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29 #error "Only <glib.h> can be included directly."
32 #include <glib/gerror.h>
38 * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character
39 * sets is not supported.
40 * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input.
41 * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason.
42 * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input.
43 * @G_CONVERT_ERROR_BAD_URI: URI is invalid.
44 * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path.
45 * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40
47 * Error codes returned by character set conversion routines.
51 G_CONVERT_ERROR_NO_CONVERSION,
52 G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
53 G_CONVERT_ERROR_FAILED,
54 G_CONVERT_ERROR_PARTIAL_INPUT,
55 G_CONVERT_ERROR_BAD_URI,
56 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH,
57 G_CONVERT_ERROR_NO_MEMORY
63 * Error domain for character set conversions. Errors in this domain will
64 * be from the #GConvertError enumeration. See #GError for information on
67 #define G_CONVERT_ERROR g_convert_error_quark()
69 GQuark g_convert_error_quark (void);
74 * The GIConv struct wraps an iconv() conversion descriptor. It contains
75 * private data and should only be accessed using the following functions.
77 typedef struct _GIConv *GIConv;
80 GIConv g_iconv_open (const gchar *to_codeset,
81 const gchar *from_codeset);
83 gsize g_iconv (GIConv converter,
87 gsize *outbytes_left);
89 gint g_iconv_close (GIConv converter);
93 gchar* g_convert (const gchar *str,
95 const gchar *to_codeset,
96 const gchar *from_codeset,
99 GError **error) G_GNUC_MALLOC;
100 GLIB_AVAILABLE_IN_ALL
101 gchar* g_convert_with_iconv (const gchar *str,
105 gsize *bytes_written,
106 GError **error) G_GNUC_MALLOC;
107 GLIB_AVAILABLE_IN_ALL
108 gchar* g_convert_with_fallback (const gchar *str,
110 const gchar *to_codeset,
111 const gchar *from_codeset,
112 const gchar *fallback,
114 gsize *bytes_written,
115 GError **error) G_GNUC_MALLOC;
118 /* Convert between libc's idea of strings and UTF-8.
120 GLIB_AVAILABLE_IN_ALL
121 gchar* g_locale_to_utf8 (const gchar *opsysstring,
124 gsize *bytes_written,
125 GError **error) G_GNUC_MALLOC;
126 GLIB_AVAILABLE_IN_ALL
127 gchar* g_locale_from_utf8 (const gchar *utf8string,
130 gsize *bytes_written,
131 GError **error) G_GNUC_MALLOC;
133 /* Convert between the operating system (or C runtime)
134 * representation of file names and UTF-8.
136 GLIB_AVAILABLE_IN_ALL
137 gchar* g_filename_to_utf8 (const gchar *opsysstring,
140 gsize *bytes_written,
141 GError **error) G_GNUC_MALLOC;
142 GLIB_AVAILABLE_IN_ALL
143 gchar* g_filename_from_utf8 (const gchar *utf8string,
146 gsize *bytes_written,
147 GError **error) G_GNUC_MALLOC;
149 GLIB_AVAILABLE_IN_ALL
150 gchar *g_filename_from_uri (const gchar *uri,
152 GError **error) G_GNUC_MALLOC;
154 GLIB_AVAILABLE_IN_ALL
155 gchar *g_filename_to_uri (const gchar *filename,
156 const gchar *hostname,
157 GError **error) G_GNUC_MALLOC;
158 GLIB_AVAILABLE_IN_ALL
159 gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
160 GLIB_AVAILABLE_IN_ALL
161 gboolean g_get_filename_charsets (const gchar ***charsets);
163 GLIB_AVAILABLE_IN_ALL
164 gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
166 GLIB_AVAILABLE_IN_ALL
167 gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC;
170 #define g_filename_to_utf8 g_filename_to_utf8_utf8
171 #define g_filename_from_utf8 g_filename_from_utf8_utf8
172 #define g_filename_from_uri g_filename_from_uri_utf8
173 #define g_filename_to_uri g_filename_to_uri_utf8
175 GLIB_AVAILABLE_IN_ALL
176 gchar* g_filename_to_utf8_utf8 (const gchar *opsysstring,
179 gsize *bytes_written,
180 GError **error) G_GNUC_MALLOC;
181 GLIB_AVAILABLE_IN_ALL
182 gchar* g_filename_from_utf8_utf8 (const gchar *utf8string,
185 gsize *bytes_written,
186 GError **error) G_GNUC_MALLOC;
187 GLIB_AVAILABLE_IN_ALL
188 gchar *g_filename_from_uri_utf8 (const gchar *uri,
190 GError **error) G_GNUC_MALLOC;
191 GLIB_AVAILABLE_IN_ALL
192 gchar *g_filename_to_uri_utf8 (const gchar *filename,
193 const gchar *hostname,
194 GError **error) G_GNUC_MALLOC;
199 #endif /* __G_CONVERT_H__ */