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