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