xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/src/msgl-iconv.h (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
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 2, or (at your option)
8    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, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18 
19 #ifndef _MSGL_ICONV_H
20 #define _MSGL_ICONV_H
21 
22 #include <stdbool.h>
23 #if HAVE_ICONV
24 #include <iconv.h>
25 #endif
26 
27 #include "message.h"
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 #if HAVE_ICONV
36 
37 /* A context, used for accurate error messages.  */
38 struct conversion_context
39 {
40   const char *from_code;     /* canonicalized encoding name for input */
41   const char *to_code;       /* canonicalized encoding name for output */
42   const char *from_filename; /* file name where the input comes from */
43   const message_ty *message; /* message being converted, or NULL */
44 };
45 
46 /* Converts the STRING through the conversion descriptor CD.  */
47 extern char *convert_string (iconv_t cd, const char *string,
48 			     const struct conversion_context* context);
49 
50 #endif
51 
52 /* Converts the message list MLP to the (already canonicalized) encoding
53    CANON_TO_CODE.  The (already canonicalized) encoding before conversion
54    can be passed as CANON_FROM_CODE; if NULL is passed instead, the
55    encoding is looked up in the header entry.  Returns true if and only if
56    some msgctxt or msgid changed due to the conversion.  */
57 extern bool
58        iconv_message_list (message_list_ty *mlp,
59 			   const char *canon_from_code,
60 			   const char *canon_to_code,
61 			   const char *from_filename);
62 
63 /* Converts all the message lists in MDLP to the encoding TO_CODE.  */
64 extern msgdomain_list_ty *
65        iconv_msgdomain_list (msgdomain_list_ty *mdlp,
66 			     const char *to_code,
67 			     const char *from_filename);
68 
69 /* Tests whether the message list MLP could be converted to CANON_TO_CODE.
70    The (already canonicalized) encoding before conversion can be passed as
71    CANON_FROM_CODE; if NULL is passed instead, the encoding is looked up
72    in the header entry.  */
73 extern bool
74        is_message_list_iconvable (message_list_ty *mlp,
75 				  const char *canon_from_code,
76 				  const char *canon_to_code);
77 
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 
84 #endif /* _MSGL_ICONV_H */
85