(root)/
gettext-0.22.4/
gettext-tools/
src/
msgl-iconv.h
       1  /* Message list character set conversion.
       2     Copyright (C) 2001-2003, 2005-2006, 2009, 2023 Free Software Foundation, Inc.
       3     Written by Bruno Haible <haible@clisp.cons.org>, 2001.
       4  
       5     This program is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU General Public License as published by
       7     the Free Software Foundation; either version 3 of the License, or
       8     (at your option) any later version.
       9  
      10     This program is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13     GNU General Public License for more details.
      14  
      15     You should have received a copy of the GNU General Public License
      16     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      17  
      18  #ifndef _MSGL_ICONV_H
      19  #define _MSGL_ICONV_H
      20  
      21  #include <stdbool.h>
      22  #if HAVE_ICONV
      23  #include <iconv.h>
      24  #endif
      25  
      26  #include "string-desc.h"
      27  
      28  #include "message.h"
      29  
      30  
      31  #ifdef __cplusplus
      32  extern "C" {
      33  #endif
      34  
      35  
      36  #if HAVE_ICONV
      37  
      38  /* A context, used for accurate error messages.  */
      39  struct conversion_context
      40  {
      41    const char *from_code;     /* canonicalized encoding name for input */
      42    const char *to_code;       /* canonicalized encoding name for output */
      43    const char *from_filename; /* file name where the input comes from */
      44    const message_ty *message; /* message being converted, or NULL */
      45  };
      46  
      47  /* Converts the STRING through the conversion descriptor CD.
      48     Assumes that either FROM_CODE or TO_CODE is UTF-8.  */
      49  extern char *convert_string_directly (iconv_t cd, const char *string,
      50                                        const struct conversion_context* context);
      51  extern string_desc_t
      52         convert_string_desc_directly (iconv_t cd, string_desc_t string,
      53                                       const struct conversion_context* context);
      54  
      55  #endif
      56  
      57  /* Converts the message list MLP to the (already canonicalized) encoding
      58     CANON_TO_CODE.  The (already canonicalized) encoding before conversion
      59     can be passed as CANON_FROM_CODE; if NULL is passed instead, the
      60     encoding is looked up in the header entry.  Returns true if and only if
      61     some msgctxt or msgid changed due to the conversion.  */
      62  extern bool
      63         iconv_message_list (message_list_ty *mlp,
      64                             const char *canon_from_code,
      65                             const char *canon_to_code,
      66                             const char *from_filename);
      67  
      68  /* Converts all the message lists in MDLP to the encoding TO_CODE.
      69     UPDATE_HEADER specifies whether to update the "charset=..." specification
      70     in the header; it should normally be true.  */
      71  extern msgdomain_list_ty *
      72         iconv_msgdomain_list (msgdomain_list_ty *mdlp,
      73                               const char *to_code,
      74                               bool update_header,
      75                               const char *from_filename);
      76  
      77  /* Tests whether the message list MLP could be converted to CANON_TO_CODE.
      78     The (already canonicalized) encoding before conversion can be passed as
      79     CANON_FROM_CODE; if NULL is passed instead, the encoding is looked up
      80     in the header entry.  */
      81  extern bool
      82         is_message_list_iconvable (message_list_ty *mlp,
      83                                    const char *canon_from_code,
      84                                    const char *canon_to_code);
      85  
      86  
      87  #ifdef __cplusplus
      88  }
      89  #endif
      90  
      91  
      92  #endif /* _MSGL_ICONV_H */