Add some more cases to the app-id unit tests
[glib.git] / glib / gconvert.h
blobba82a65e90631c6c113d4f3f7fccb3f3f1897576
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."
30 #endif
32 #include <glib/gerror.h>
34 G_BEGIN_DECLS
36 /**
37 * GConvertError:
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.
49 typedef enum
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
58 } GConvertError;
60 /**
61 * G_CONVERT_ERROR:
63 * Error domain for character set conversions. Errors in this domain will
64 * be from the #GConvertError enumeration. See #GError for information on
65 * error domains.
67 #define G_CONVERT_ERROR g_convert_error_quark()
68 GLIB_AVAILABLE_IN_ALL
69 GQuark g_convert_error_quark (void);
71 /**
72 * GIConv:
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;
79 GLIB_AVAILABLE_IN_ALL
80 GIConv g_iconv_open (const gchar *to_codeset,
81 const gchar *from_codeset);
82 GLIB_AVAILABLE_IN_ALL
83 gsize g_iconv (GIConv converter,
84 gchar **inbuf,
85 gsize *inbytes_left,
86 gchar **outbuf,
87 gsize *outbytes_left);
88 GLIB_AVAILABLE_IN_ALL
89 gint g_iconv_close (GIConv converter);
92 GLIB_AVAILABLE_IN_ALL
93 gchar* g_convert (const gchar *str,
94 gssize len,
95 const gchar *to_codeset,
96 const gchar *from_codeset,
97 gsize *bytes_read,
98 gsize *bytes_written,
99 GError **error) G_GNUC_MALLOC;
100 GLIB_AVAILABLE_IN_ALL
101 gchar* g_convert_with_iconv (const gchar *str,
102 gssize len,
103 GIConv converter,
104 gsize *bytes_read,
105 gsize *bytes_written,
106 GError **error) G_GNUC_MALLOC;
107 GLIB_AVAILABLE_IN_ALL
108 gchar* g_convert_with_fallback (const gchar *str,
109 gssize len,
110 const gchar *to_codeset,
111 const gchar *from_codeset,
112 const gchar *fallback,
113 gsize *bytes_read,
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,
122 gssize len,
123 gsize *bytes_read,
124 gsize *bytes_written,
125 GError **error) G_GNUC_MALLOC;
126 GLIB_AVAILABLE_IN_ALL
127 gchar* g_locale_from_utf8 (const gchar *utf8string,
128 gssize len,
129 gsize *bytes_read,
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,
138 gssize len,
139 gsize *bytes_read,
140 gsize *bytes_written,
141 GError **error) G_GNUC_MALLOC;
142 GLIB_AVAILABLE_IN_ALL
143 gchar* g_filename_from_utf8 (const gchar *utf8string,
144 gssize len,
145 gsize *bytes_read,
146 gsize *bytes_written,
147 GError **error) G_GNUC_MALLOC;
149 GLIB_AVAILABLE_IN_ALL
150 gchar *g_filename_from_uri (const gchar *uri,
151 gchar **hostname,
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;
169 #ifndef __GTK_DOC_IGNORE__
170 #ifdef G_OS_WIN32
171 #define g_filename_to_utf8 g_filename_to_utf8_utf8
172 #define g_filename_from_utf8 g_filename_from_utf8_utf8
173 #define g_filename_from_uri g_filename_from_uri_utf8
174 #define g_filename_to_uri g_filename_to_uri_utf8
176 GLIB_AVAILABLE_IN_ALL
177 gchar* g_filename_to_utf8_utf8 (const gchar *opsysstring,
178 gssize len,
179 gsize *bytes_read,
180 gsize *bytes_written,
181 GError **error) G_GNUC_MALLOC;
182 GLIB_AVAILABLE_IN_ALL
183 gchar* g_filename_from_utf8_utf8 (const gchar *utf8string,
184 gssize len,
185 gsize *bytes_read,
186 gsize *bytes_written,
187 GError **error) G_GNUC_MALLOC;
188 GLIB_AVAILABLE_IN_ALL
189 gchar *g_filename_from_uri_utf8 (const gchar *uri,
190 gchar **hostname,
191 GError **error) G_GNUC_MALLOC;
192 GLIB_AVAILABLE_IN_ALL
193 gchar *g_filename_to_uri_utf8 (const gchar *filename,
194 const gchar *hostname,
195 GError **error) G_GNUC_MALLOC;
196 #endif
197 #endif /* __GTK_DOC_IGNORE__ */
199 G_END_DECLS
201 #endif /* __G_CONVERT_H__ */