Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / src / msgl-iconv.h
1 /* Message list character set conversion.
2    Copyright (C) 2001-2003, 2005-2006, 2009, 2015 Free Software
3    Foundation, Inc.
4    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program 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
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
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    Assumes that either FROM_CODE or TO_CODE is UTF-8.  */
48 extern char *convert_string_directly (iconv_t cd, const char *string,
49                                       const struct conversion_context* context);
50
51 #endif
52
53 /* Converts the message list MLP to the (already canonicalized) encoding
54    CANON_TO_CODE.  The (already canonicalized) encoding before conversion
55    can be passed as CANON_FROM_CODE; if NULL is passed instead, the
56    encoding is looked up in the header entry.  Returns true if and only if
57    some msgctxt or msgid changed due to the conversion.  */
58 extern bool
59        iconv_message_list (message_list_ty *mlp,
60                            const char *canon_from_code,
61                            const char *canon_to_code,
62                            const char *from_filename);
63
64 /* Converts all the message lists in MDLP to the encoding TO_CODE.
65    UPDATE_HEADER specifies whether to update the "charset=..." specification
66    in the header; it should normally be true.  */
67 extern msgdomain_list_ty *
68        iconv_msgdomain_list (msgdomain_list_ty *mdlp,
69                              const char *to_code,
70                              bool update_header,
71                              const char *from_filename);
72
73 /* Tests whether the message list MLP could be converted to CANON_TO_CODE.
74    The (already canonicalized) encoding before conversion can be passed as
75    CANON_FROM_CODE; if NULL is passed instead, the encoding is looked up
76    in the header entry.  */
77 extern bool
78        is_message_list_iconvable (message_list_ty *mlp,
79                                   const char *canon_from_code,
80                                   const char *canon_to_code);
81
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87
88 #endif /* _MSGL_ICONV_H */