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.1 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 | |
34 | G_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 | * or the character sequence could not be represented in the target |
42 | * character set. |
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 |
48 | * @G_CONVERT_ERROR_EMBEDDED_NUL: An embedded NUL character is present in |
49 | * conversion output where a NUL-terminated string is expected. |
50 | * Since: 2.56 |
51 | * |
52 | * Error codes returned by character set conversion routines. |
53 | */ |
54 | typedef enum |
55 | { |
56 | G_CONVERT_ERROR_NO_CONVERSION, |
57 | G_CONVERT_ERROR_ILLEGAL_SEQUENCE, |
58 | G_CONVERT_ERROR_FAILED, |
59 | G_CONVERT_ERROR_PARTIAL_INPUT, |
60 | G_CONVERT_ERROR_BAD_URI, |
61 | G_CONVERT_ERROR_NOT_ABSOLUTE_PATH, |
62 | G_CONVERT_ERROR_NO_MEMORY, |
63 | G_CONVERT_ERROR_EMBEDDED_NUL |
64 | } GConvertError; |
65 | |
66 | /** |
67 | * G_CONVERT_ERROR: |
68 | * |
69 | * Error domain for character set conversions. Errors in this domain will |
70 | * be from the #GConvertError enumeration. See #GError for information on |
71 | * error domains. |
72 | */ |
73 | #define G_CONVERT_ERROR g_convert_error_quark() |
74 | GLIB_AVAILABLE_IN_ALL |
75 | GQuark g_convert_error_quark (void); |
76 | |
77 | /** |
78 | * GIConv: (skip) |
79 | * |
80 | * The GIConv struct wraps an iconv() conversion descriptor. It contains |
81 | * private data and should only be accessed using the following functions. |
82 | */ |
83 | typedef struct _GIConv *GIConv; |
84 | |
85 | GLIB_AVAILABLE_IN_ALL |
86 | GIConv g_iconv_open (const gchar *to_codeset, |
87 | const gchar *from_codeset); |
88 | GLIB_AVAILABLE_IN_ALL |
89 | gsize g_iconv (GIConv converter, |
90 | gchar **inbuf, |
91 | gsize *inbytes_left, |
92 | gchar **outbuf, |
93 | gsize *outbytes_left); |
94 | GLIB_AVAILABLE_IN_ALL |
95 | gint g_iconv_close (GIConv converter); |
96 | |
97 | |
98 | GLIB_AVAILABLE_IN_ALL |
99 | gchar* g_convert (const gchar *str, |
100 | gssize len, |
101 | const gchar *to_codeset, |
102 | const gchar *from_codeset, |
103 | gsize *bytes_read, |
104 | gsize *bytes_written, |
105 | GError **error) G_GNUC_MALLOC; |
106 | GLIB_AVAILABLE_IN_ALL |
107 | gchar* g_convert_with_iconv (const gchar *str, |
108 | gssize len, |
109 | GIConv converter, |
110 | gsize *bytes_read, |
111 | gsize *bytes_written, |
112 | GError **error) G_GNUC_MALLOC; |
113 | GLIB_AVAILABLE_IN_ALL |
114 | gchar* g_convert_with_fallback (const gchar *str, |
115 | gssize len, |
116 | const gchar *to_codeset, |
117 | const gchar *from_codeset, |
118 | const gchar *fallback, |
119 | gsize *bytes_read, |
120 | gsize *bytes_written, |
121 | GError **error) G_GNUC_MALLOC; |
122 | |
123 | |
124 | /* Convert between libc's idea of strings and UTF-8. |
125 | */ |
126 | GLIB_AVAILABLE_IN_ALL |
127 | gchar* g_locale_to_utf8 (const gchar *opsysstring, |
128 | gssize len, |
129 | gsize *bytes_read, |
130 | gsize *bytes_written, |
131 | GError **error) G_GNUC_MALLOC; |
132 | GLIB_AVAILABLE_IN_ALL |
133 | gchar* g_locale_from_utf8 (const gchar *utf8string, |
134 | gssize len, |
135 | gsize *bytes_read, |
136 | gsize *bytes_written, |
137 | GError **error) G_GNUC_MALLOC; |
138 | |
139 | /* Convert between the operating system (or C runtime) |
140 | * representation of file names and UTF-8. |
141 | */ |
142 | GLIB_AVAILABLE_IN_ALL |
143 | gchar* g_filename_to_utf8 (const gchar *opsysstring, |
144 | gssize len, |
145 | gsize *bytes_read, |
146 | gsize *bytes_written, |
147 | GError **error) G_GNUC_MALLOC; |
148 | GLIB_AVAILABLE_IN_ALL |
149 | gchar* g_filename_from_utf8 (const gchar *utf8string, |
150 | gssize len, |
151 | gsize *bytes_read, |
152 | gsize *bytes_written, |
153 | GError **error) G_GNUC_MALLOC; |
154 | |
155 | GLIB_AVAILABLE_IN_ALL |
156 | gchar *g_filename_from_uri (const gchar *uri, |
157 | gchar **hostname, |
158 | GError **error) G_GNUC_MALLOC; |
159 | |
160 | GLIB_AVAILABLE_IN_ALL |
161 | gchar *g_filename_to_uri (const gchar *filename, |
162 | const gchar *hostname, |
163 | GError **error) G_GNUC_MALLOC; |
164 | GLIB_AVAILABLE_IN_ALL |
165 | gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC; |
166 | GLIB_AVAILABLE_IN_ALL |
167 | gboolean g_get_filename_charsets (const gchar ***charsets); |
168 | |
169 | GLIB_AVAILABLE_IN_ALL |
170 | gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; |
171 | |
172 | GLIB_AVAILABLE_IN_ALL |
173 | gchar ** (const gchar *uri_list); |
174 | |
175 | G_END_DECLS |
176 | |
177 | #endif /* __G_CONVERT_H__ */ |
178 | |