gconvert.h 5.8 KB

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