gconvert.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* GLIB - Library of useful routines for C programming
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * SPDX-License-Identifier: LGPL-2.1-or-later
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /*
  20. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GLib Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #ifndef __G_CONVERT_H__
  26. #define __G_CONVERT_H__
  27. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  28. #error "Only <glib.h> can be included directly."
  29. #endif
  30. #include <glib/gerror.h>
  31. G_BEGIN_DECLS
  32. /**
  33. * GConvertError:
  34. * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character
  35. * sets is not supported.
  36. * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input;
  37. * or the character sequence could not be represented in the target
  38. * character set.
  39. * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason.
  40. * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input.
  41. * @G_CONVERT_ERROR_BAD_URI: URI is invalid.
  42. * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path.
  43. * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40
  44. * @G_CONVERT_ERROR_EMBEDDED_NUL: An embedded NUL character is present in
  45. * conversion output where a NUL-terminated string is expected.
  46. * Since: 2.56
  47. *
  48. * Error codes returned by character set conversion routines.
  49. */
  50. typedef enum
  51. {
  52. G_CONVERT_ERROR_NO_CONVERSION,
  53. G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
  54. G_CONVERT_ERROR_FAILED,
  55. G_CONVERT_ERROR_PARTIAL_INPUT,
  56. G_CONVERT_ERROR_BAD_URI,
  57. G_CONVERT_ERROR_NOT_ABSOLUTE_PATH,
  58. G_CONVERT_ERROR_NO_MEMORY,
  59. G_CONVERT_ERROR_EMBEDDED_NUL
  60. } GConvertError;
  61. /**
  62. * G_CONVERT_ERROR:
  63. *
  64. * Error domain for character set conversions. Errors in this domain will
  65. * be from the #GConvertError enumeration. See #GError for information on
  66. * error domains.
  67. */
  68. #define G_CONVERT_ERROR g_convert_error_quark()
  69. GLIB_AVAILABLE_IN_ALL
  70. GQuark g_convert_error_quark (void);
  71. /**
  72. * GIConv: (skip)
  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. */
  77. typedef struct _GIConv *GIConv;
  78. GLIB_AVAILABLE_IN_ALL
  79. GIConv g_iconv_open (const gchar *to_codeset,
  80. const gchar *from_codeset);
  81. GLIB_AVAILABLE_IN_ALL
  82. gsize g_iconv (GIConv converter,
  83. gchar **inbuf,
  84. gsize *inbytes_left,
  85. gchar **outbuf,
  86. gsize *outbytes_left);
  87. GLIB_AVAILABLE_IN_ALL
  88. gint g_iconv_close (GIConv converter);
  89. GLIB_AVAILABLE_IN_ALL
  90. gchar* g_convert (const gchar *str,
  91. gssize len,
  92. const gchar *to_codeset,
  93. const gchar *from_codeset,
  94. gsize *bytes_read,
  95. gsize *bytes_written,
  96. GError **error) G_GNUC_MALLOC;
  97. GLIB_AVAILABLE_IN_ALL
  98. gchar* g_convert_with_iconv (const gchar *str,
  99. gssize len,
  100. GIConv converter,
  101. gsize *bytes_read,
  102. gsize *bytes_written,
  103. GError **error) G_GNUC_MALLOC;
  104. GLIB_AVAILABLE_IN_ALL
  105. gchar* g_convert_with_fallback (const gchar *str,
  106. gssize len,
  107. const gchar *to_codeset,
  108. const gchar *from_codeset,
  109. const gchar *fallback,
  110. gsize *bytes_read,
  111. gsize *bytes_written,
  112. GError **error) G_GNUC_MALLOC;
  113. /* Convert between libc's idea of strings and UTF-8.
  114. */
  115. GLIB_AVAILABLE_IN_ALL
  116. gchar* g_locale_to_utf8 (const gchar *opsysstring,
  117. gssize len,
  118. gsize *bytes_read,
  119. gsize *bytes_written,
  120. GError **error) G_GNUC_MALLOC;
  121. GLIB_AVAILABLE_IN_ALL
  122. gchar* g_locale_from_utf8 (const gchar *utf8string,
  123. gssize len,
  124. gsize *bytes_read,
  125. gsize *bytes_written,
  126. GError **error) G_GNUC_MALLOC;
  127. /* Convert between the operating system (or C runtime)
  128. * representation of file names and UTF-8.
  129. */
  130. GLIB_AVAILABLE_IN_ALL
  131. gchar* g_filename_to_utf8 (const gchar *opsysstring,
  132. gssize len,
  133. gsize *bytes_read,
  134. gsize *bytes_written,
  135. GError **error) G_GNUC_MALLOC;
  136. GLIB_AVAILABLE_IN_ALL
  137. gchar* g_filename_from_utf8 (const gchar *utf8string,
  138. gssize len,
  139. gsize *bytes_read,
  140. gsize *bytes_written,
  141. GError **error) G_GNUC_MALLOC;
  142. GLIB_AVAILABLE_IN_ALL
  143. gchar *g_filename_from_uri (const gchar *uri,
  144. gchar **hostname,
  145. GError **error) G_GNUC_MALLOC;
  146. GLIB_AVAILABLE_IN_ALL
  147. gchar *g_filename_to_uri (const gchar *filename,
  148. const gchar *hostname,
  149. GError **error) G_GNUC_MALLOC;
  150. GLIB_AVAILABLE_IN_ALL
  151. gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC;
  152. GLIB_AVAILABLE_IN_ALL
  153. gboolean g_get_filename_charsets (const gchar ***filename_charsets);
  154. GLIB_AVAILABLE_IN_ALL
  155. gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
  156. GLIB_AVAILABLE_IN_ALL
  157. gchar **g_uri_list_extract_uris (const gchar *uri_list);
  158. G_END_DECLS
  159. #endif /* __G_CONVERT_H__ */