1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
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.
8 *
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.
13 *
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/>.
16 */
17
18/*
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/.
23 */
24
25#ifndef __G_CONVERT_H__
26#define __G_CONVERT_H__
27
28#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29#error "Only <glib.h> can be included directly."
30#endif
31
32#include <glib/gerror.h>
33
34G_BEGIN_DECLS
35
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
46 *
47 * Error codes returned by character set conversion routines.
48 */
49typedef enum
50{
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;
59
60/**
61 * G_CONVERT_ERROR:
62 *
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.
66 */
67#define G_CONVERT_ERROR g_convert_error_quark()
68GLIB_AVAILABLE_IN_ALL
69GQuark g_convert_error_quark (void);
70
71/**
72 * GIConv:
73 *
74 * The GIConv struct wraps an iconv() conversion descriptor. It contains
75 * private data and should only be accessed using the following functions.
76 */
77typedef struct _GIConv *GIConv;
78
79GLIB_AVAILABLE_IN_ALL
80GIConv g_iconv_open (const gchar *to_codeset,
81 const gchar *from_codeset);
82GLIB_AVAILABLE_IN_ALL
83gsize g_iconv (GIConv converter,
84 gchar **inbuf,
85 gsize *inbytes_left,
86 gchar **outbuf,
87 gsize *outbytes_left);
88GLIB_AVAILABLE_IN_ALL
89gint g_iconv_close (GIConv converter);
90
91
92GLIB_AVAILABLE_IN_ALL
93gchar* 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;
100GLIB_AVAILABLE_IN_ALL
101gchar* 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;
107GLIB_AVAILABLE_IN_ALL
108gchar* 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;
116
117
118/* Convert between libc's idea of strings and UTF-8.
119 */
120GLIB_AVAILABLE_IN_ALL
121gchar* g_locale_to_utf8 (const gchar *opsysstring,
122 gssize len,
123 gsize *bytes_read,
124 gsize *bytes_written,
125 GError **error) G_GNUC_MALLOC;
126GLIB_AVAILABLE_IN_ALL
127gchar* g_locale_from_utf8 (const gchar *utf8string,
128 gssize len,
129 gsize *bytes_read,
130 gsize *bytes_written,
131 GError **error) G_GNUC_MALLOC;
132
133/* Convert between the operating system (or C runtime)
134 * representation of file names and UTF-8.
135 */
136GLIB_AVAILABLE_IN_ALL
137gchar* g_filename_to_utf8 (const gchar *opsysstring,
138 gssize len,
139 gsize *bytes_read,
140 gsize *bytes_written,
141 GError **error) G_GNUC_MALLOC;
142GLIB_AVAILABLE_IN_ALL
143gchar* g_filename_from_utf8 (const gchar *utf8string,
144 gssize len,
145 gsize *bytes_read,
146 gsize *bytes_written,
147 GError **error) G_GNUC_MALLOC;
148
149GLIB_AVAILABLE_IN_ALL
150gchar *g_filename_from_uri (const gchar *uri,
151 gchar **hostname,
152 GError **error) G_GNUC_MALLOC;
153
154GLIB_AVAILABLE_IN_ALL
155gchar *g_filename_to_uri (const gchar *filename,
156 const gchar *hostname,
157 GError **error) G_GNUC_MALLOC;
158GLIB_AVAILABLE_IN_ALL
159gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
160GLIB_AVAILABLE_IN_ALL
161gboolean g_get_filename_charsets (const gchar ***charsets);
162
163GLIB_AVAILABLE_IN_ALL
164gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
165
166GLIB_AVAILABLE_IN_ALL
167gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC;
168
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
175
176GLIB_AVAILABLE_IN_ALL
177gchar* 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;
182GLIB_AVAILABLE_IN_ALL
183gchar* 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;
188GLIB_AVAILABLE_IN_ALL
189gchar *g_filename_from_uri_utf8 (const gchar *uri,
190 gchar **hostname,
191 GError **error) G_GNUC_MALLOC;
192GLIB_AVAILABLE_IN_ALL
193gchar *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__ */
198
199G_END_DECLS
200
201#endif /* __G_CONVERT_H__ */
202