1/* Message list character set conversion. 2 Copyright (C) 2001-2003, 2005-2006 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 <http://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 "message.h" 27 28 29#ifdef __cplusplus 30extern "C" { 31#endif 32 33 34#if HAVE_ICONV 35 36/* A context, used for accurate error messages. */ 37struct conversion_context 38{ 39 const char *from_code; /* canonicalized encoding name for input */ 40 const char *to_code; /* canonicalized encoding name for output */ 41 const char *from_filename; /* file name where the input comes from */ 42 const message_ty *message; /* message being converted, or NULL */ 43}; 44 45/* Converts the STRING through the conversion descriptor CD. */ 46extern char *convert_string (iconv_t cd, const char *string, 47 const struct conversion_context* context); 48 49#endif 50 51/* Converts the message list MLP to the (already canonicalized) encoding 52 CANON_TO_CODE. The (already canonicalized) encoding before conversion 53 can be passed as CANON_FROM_CODE; if NULL is passed instead, the 54 encoding is looked up in the header entry. Returns true if and only if 55 some msgctxt or msgid changed due to the conversion. */ 56extern bool 57 iconv_message_list (message_list_ty *mlp, 58 const char *canon_from_code, 59 const char *canon_to_code, 60 const char *from_filename); 61 62/* Converts all the message lists in MDLP to the encoding TO_CODE. 63 UPDATE_HEADER specifies whether to update the "charset=..." specification 64 in the header; it should normally be true. */ 65extern msgdomain_list_ty * 66 iconv_msgdomain_list (msgdomain_list_ty *mdlp, 67 const char *to_code, 68 bool update_header, 69 const char *from_filename); 70 71/* Tests whether the message list MLP could be converted to CANON_TO_CODE. 72 The (already canonicalized) encoding before conversion can be passed as 73 CANON_FROM_CODE; if NULL is passed instead, the encoding is looked up 74 in the header entry. */ 75extern bool 76 is_message_list_iconvable (message_list_ty *mlp, 77 const char *canon_from_code, 78 const char *canon_to_code); 79 80 81#ifdef __cplusplus 82} 83#endif 84 85 86#endif /* _MSGL_ICONV_H */ 87