gconvert.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  19. * file for a list of people on the GLib Team. See the ChangeLog
  20. * files for a list of changes. These files are distributed with
  21. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  22. */
  23. #ifndef __G_CONVERT_H__
  24. #define __G_CONVERT_H__
  25. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #include <glib/gerror.h>
  29. G_BEGIN_DECLS
  30. /**
  31. * GConvertError:
  32. * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character
  33. * sets is not supported.
  34. * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input.
  35. * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason.
  36. * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input.
  37. * @G_CONVERT_ERROR_BAD_URI: URI is invalid.
  38. * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path.
  39. * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40
  40. *
  41. * Error codes returned by character set conversion routines.
  42. */
  43. typedef enum
  44. {
  45. G_CONVERT_ERROR_NO_CONVERSION,
  46. G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
  47. G_CONVERT_ERROR_FAILED,
  48. G_CONVERT_ERROR_PARTIAL_INPUT,
  49. G_CONVERT_ERROR_BAD_URI,
  50. G_CONVERT_ERROR_NOT_ABSOLUTE_PATH,
  51. G_CONVERT_ERROR_NO_MEMORY
  52. } GConvertError;
  53. /**
  54. * G_CONVERT_ERROR:
  55. *
  56. * Error domain for character set conversions. Errors in this domain will
  57. * be from the #GConvertError enumeration. See #GError for information on
  58. * error domains.
  59. */
  60. #define G_CONVERT_ERROR g_convert_error_quark()
  61. GLIB_AVAILABLE_IN_ALL
  62. GQuark g_convert_error_quark (void);
  63. /**
  64. * GIConv:
  65. *
  66. * The GIConv struct wraps an iconv() conversion descriptor. It contains
  67. * private data and should only be accessed using the following functions.
  68. */
  69. typedef struct _GIConv *GIConv;
  70. GLIB_AVAILABLE_IN_ALL
  71. GIConv g_iconv_open (const gchar *to_codeset,
  72. const gchar *from_codeset);
  73. GLIB_AVAILABLE_IN_ALL
  74. gsize g_iconv (GIConv converter,
  75. gchar **inbuf,
  76. gsize *inbytes_left,
  77. gchar **outbuf,
  78. gsize *outbytes_left);
  79. GLIB_AVAILABLE_IN_ALL
  80. gint g_iconv_close (GIConv converter);
  81. GLIB_AVAILABLE_IN_ALL
  82. gchar* g_convert (const gchar *str,
  83. gssize len,
  84. const gchar *to_codeset,
  85. const gchar *from_codeset,
  86. gsize *bytes_read,
  87. gsize *bytes_written,
  88. GError **error) G_GNUC_MALLOC;
  89. GLIB_AVAILABLE_IN_ALL
  90. gchar* g_convert_with_iconv (const gchar *str,
  91. gssize len,
  92. GIConv converter,
  93. gsize *bytes_read,
  94. gsize *bytes_written,
  95. GError **error) G_GNUC_MALLOC;
  96. GLIB_AVAILABLE_IN_ALL
  97. gchar* g_convert_with_fallback (const gchar *str,
  98. gssize len,
  99. const gchar *to_codeset,
  100. const gchar *from_codeset,
  101. const gchar *fallback,
  102. gsize *bytes_read,
  103. gsize *bytes_written,
  104. GError **error) G_GNUC_MALLOC;
  105. /* Convert between libc's idea of strings and UTF-8.
  106. */
  107. GLIB_AVAILABLE_IN_ALL
  108. gchar* g_locale_to_utf8 (const gchar *opsysstring,
  109. gssize len,
  110. gsize *bytes_read,
  111. gsize *bytes_written,
  112. GError **error) G_GNUC_MALLOC;
  113. GLIB_AVAILABLE_IN_ALL
  114. gchar* g_locale_from_utf8 (const gchar *utf8string,
  115. gssize len,
  116. gsize *bytes_read,
  117. gsize *bytes_written,
  118. GError **error) G_GNUC_MALLOC;
  119. /* Convert between the operating system (or C runtime)
  120. * representation of file names and UTF-8.
  121. */
  122. GLIB_AVAILABLE_IN_ALL
  123. gchar* g_filename_to_utf8 (const gchar *opsysstring,
  124. gssize len,
  125. gsize *bytes_read,
  126. gsize *bytes_written,
  127. GError **error) G_GNUC_MALLOC;
  128. GLIB_AVAILABLE_IN_ALL
  129. gchar* g_filename_from_utf8 (const gchar *utf8string,
  130. gssize len,
  131. gsize *bytes_read,
  132. gsize *bytes_written,
  133. GError **error) G_GNUC_MALLOC;
  134. GLIB_AVAILABLE_IN_ALL
  135. gchar *g_filename_from_uri (const gchar *uri,
  136. gchar **hostname,
  137. GError **error) G_GNUC_MALLOC;
  138. GLIB_AVAILABLE_IN_ALL
  139. gchar *g_filename_to_uri (const gchar *filename,
  140. const gchar *hostname,
  141. GError **error) G_GNUC_MALLOC;
  142. GLIB_AVAILABLE_IN_ALL
  143. gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
  144. GLIB_AVAILABLE_IN_ALL
  145. gboolean g_get_filename_charsets (const gchar ***charsets);
  146. GLIB_AVAILABLE_IN_ALL
  147. gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
  148. GLIB_AVAILABLE_IN_ALL
  149. gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC;
  150. #ifndef __GTK_DOC_IGNORE__
  151. #ifdef G_OS_WIN32
  152. #define g_filename_to_utf8 g_filename_to_utf8_utf8
  153. #define g_filename_from_utf8 g_filename_from_utf8_utf8
  154. #define g_filename_from_uri g_filename_from_uri_utf8
  155. #define g_filename_to_uri g_filename_to_uri_utf8
  156. GLIB_AVAILABLE_IN_ALL
  157. gchar* g_filename_to_utf8_utf8 (const gchar *opsysstring,
  158. gssize len,
  159. gsize *bytes_read,
  160. gsize *bytes_written,
  161. GError **error) G_GNUC_MALLOC;
  162. GLIB_AVAILABLE_IN_ALL
  163. gchar* g_filename_from_utf8_utf8 (const gchar *utf8string,
  164. gssize len,
  165. gsize *bytes_read,
  166. gsize *bytes_written,
  167. GError **error) G_GNUC_MALLOC;
  168. GLIB_AVAILABLE_IN_ALL
  169. gchar *g_filename_from_uri_utf8 (const gchar *uri,
  170. gchar **hostname,
  171. GError **error) G_GNUC_MALLOC;
  172. GLIB_AVAILABLE_IN_ALL
  173. gchar *g_filename_to_uri_utf8 (const gchar *filename,
  174. const gchar *hostname,
  175. GError **error) G_GNUC_MALLOC;
  176. #endif
  177. #endif /* __GTK_DOC_IGNORE__ */
  178. G_END_DECLS
  179. #endif /* __G_CONVERT_H__ */