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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
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 * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason.
44 * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input.
45 * @G_CONVERT_ERROR_BAD_URI: URI is invalid.
46 * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path.
47 * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40
49 * Error codes returned by character set conversion routines.
53 G_CONVERT_ERROR_NO_CONVERSION,
54 G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
55 G_CONVERT_ERROR_FAILED,
56 G_CONVERT_ERROR_PARTIAL_INPUT,
57 G_CONVERT_ERROR_BAD_URI,
58 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH,
59 G_CONVERT_ERROR_NO_MEMORY
65 * Error domain for character set conversions. Errors in this domain will
66 * be from the #GConvertError enumeration. See #GError for information on
69 #define G_CONVERT_ERROR g_convert_error_quark()
71 GQuark g_convert_error_quark (void);
76 * The <structname>GIConv</structname> struct wraps an
77 * iconv() conversion descriptor. It contains private data
78 * and should only be accessed using the following functions.
80 typedef struct _GIConv *GIConv;
83 GIConv g_iconv_open (const gchar *to_codeset,
84 const gchar *from_codeset);
86 gsize g_iconv (GIConv converter,
90 gsize *outbytes_left);
92 gint g_iconv_close (GIConv converter);
96 gchar* g_convert (const gchar *str,
98 const gchar *to_codeset,
99 const gchar *from_codeset,
101 gsize *bytes_written,
102 GError **error) G_GNUC_MALLOC;
103 GLIB_AVAILABLE_IN_ALL
104 gchar* g_convert_with_iconv (const gchar *str,
108 gsize *bytes_written,
109 GError **error) G_GNUC_MALLOC;
110 GLIB_AVAILABLE_IN_ALL
111 gchar* g_convert_with_fallback (const gchar *str,
113 const gchar *to_codeset,
114 const gchar *from_codeset,
115 const gchar *fallback,
117 gsize *bytes_written,
118 GError **error) G_GNUC_MALLOC;
121 /* Convert between libc's idea of strings and UTF-8.
123 GLIB_AVAILABLE_IN_ALL
124 gchar* g_locale_to_utf8 (const gchar *opsysstring,
127 gsize *bytes_written,
128 GError **error) G_GNUC_MALLOC;
129 GLIB_AVAILABLE_IN_ALL
130 gchar* g_locale_from_utf8 (const gchar *utf8string,
133 gsize *bytes_written,
134 GError **error) G_GNUC_MALLOC;
136 /* Convert between the operating system (or C runtime)
137 * representation of file names and UTF-8.
139 GLIB_AVAILABLE_IN_ALL
140 gchar* g_filename_to_utf8 (const gchar *opsysstring,
143 gsize *bytes_written,
144 GError **error) G_GNUC_MALLOC;
145 GLIB_AVAILABLE_IN_ALL
146 gchar* g_filename_from_utf8 (const gchar *utf8string,
149 gsize *bytes_written,
150 GError **error) G_GNUC_MALLOC;
152 GLIB_AVAILABLE_IN_ALL
153 gchar *g_filename_from_uri (const gchar *uri,
155 GError **error) G_GNUC_MALLOC;
157 GLIB_AVAILABLE_IN_ALL
158 gchar *g_filename_to_uri (const gchar *filename,
159 const gchar *hostname,
160 GError **error) G_GNUC_MALLOC;
161 GLIB_AVAILABLE_IN_ALL
162 gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
163 GLIB_AVAILABLE_IN_ALL
164 gboolean g_get_filename_charsets (const gchar ***charsets);
166 GLIB_AVAILABLE_IN_ALL
167 gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
169 GLIB_AVAILABLE_IN_ALL
170 gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC;
173 #define g_filename_to_utf8 g_filename_to_utf8_utf8
174 #define g_filename_from_utf8 g_filename_from_utf8_utf8
175 #define g_filename_from_uri g_filename_from_uri_utf8
176 #define g_filename_to_uri g_filename_to_uri_utf8
178 GLIB_AVAILABLE_IN_ALL
179 gchar* g_filename_to_utf8_utf8 (const gchar *opsysstring,
182 gsize *bytes_written,
183 GError **error) G_GNUC_MALLOC;
184 GLIB_AVAILABLE_IN_ALL
185 gchar* g_filename_from_utf8_utf8 (const gchar *utf8string,
188 gsize *bytes_written,
189 GError **error) G_GNUC_MALLOC;
190 GLIB_AVAILABLE_IN_ALL
191 gchar *g_filename_from_uri_utf8 (const gchar *uri,
193 GError **error) G_GNUC_MALLOC;
194 GLIB_AVAILABLE_IN_ALL
195 gchar *g_filename_to_uri_utf8 (const gchar *filename,
196 const gchar *hostname,
197 GError **error) G_GNUC_MALLOC;
202 #endif /* __G_CONVERT_H__ */