2005-01-20 [colin] 1.0.0cvs3.3
[claws.git] / src / codeconv.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2004 Hiroyuki Yamamoto
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 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, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __CODECONV_H__
21 #define __CODECONV_H__
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <glib.h>
28
29 typedef struct _CodeConverter   CodeConverter;
30
31 typedef enum
32 {
33         C_AUTO,
34         C_US_ASCII,
35         C_UTF_8,
36         C_UTF_7,
37         C_ISO_8859_1,
38         C_ISO_8859_2,
39         C_ISO_8859_3,
40         C_ISO_8859_4,
41         C_ISO_8859_5,
42         C_ISO_8859_6,
43         C_ISO_8859_7,
44         C_ISO_8859_8,
45         C_ISO_8859_9,
46         C_ISO_8859_10,
47         C_ISO_8859_11,
48         C_ISO_8859_13,
49         C_ISO_8859_14,
50         C_ISO_8859_15,
51         C_BALTIC,
52         C_CP1250,
53         C_CP1251,
54         C_CP1252,
55         C_CP1253,
56         C_CP1254,
57         C_CP1255,
58         C_CP1256,
59         C_CP1257,
60         C_CP1258,
61         C_WINDOWS_1250,
62         C_WINDOWS_1251,
63         C_WINDOWS_1252,
64         C_WINDOWS_1253,
65         C_WINDOWS_1254,
66         C_WINDOWS_1255,
67         C_WINDOWS_1256,
68         C_WINDOWS_1257,
69         C_WINDOWS_1258,
70         C_KOI8_R,
71         C_KOI8_T,
72         C_KOI8_U,
73         C_ISO_2022_JP,
74         C_ISO_2022_JP_2,
75         C_ISO_2022_JP_3,
76         C_EUC_JP,
77         C_SHIFT_JIS,
78         C_ISO_2022_KR,
79         C_EUC_KR,
80         C_ISO_2022_CN,
81         C_EUC_CN,
82         C_GB2312,
83         C_GBK,
84         C_EUC_TW,
85         C_BIG5,
86         C_BIG5_HKSCS,
87         C_TIS_620,
88         C_WINDOWS_874,
89         C_GEORGIAN_PS,
90         C_TCVN5712_1
91 } CharSet;
92
93 typedef void (*CodeConvFunc) (gchar *outbuf, gint outlen, const gchar *inbuf);
94
95 struct _CodeConverter
96 {
97         CodeConvFunc code_conv_func;
98         gchar *charset_str;
99         CharSet charset;
100 };
101
102 #define CS_AUTO                 "AUTO"
103 #define CS_US_ASCII             "US-ASCII"
104 #define CS_ANSI_X3_4_1968       "ANSI_X3.4-1968"
105 #define CS_UTF_8                "UTF-8"
106 #define CS_UTF_7                "UTF-7"
107 #define CS_ISO_8859_1           "ISO-8859-1"
108 #define CS_ISO_8859_2           "ISO-8859-2"
109 #define CS_ISO_8859_3           "ISO-8859-3"
110 #define CS_ISO_8859_4           "ISO-8859-4"
111 #define CS_ISO_8859_5           "ISO-8859-5"
112 #define CS_ISO_8859_6           "ISO-8859-6"
113 #define CS_ISO_8859_7           "ISO-8859-7"
114 #define CS_ISO_8859_8           "ISO-8859-8"
115 #define CS_ISO_8859_9           "ISO-8859-9"
116 #define CS_ISO_8859_10          "ISO-8859-10"
117 #define CS_ISO_8859_11          "ISO-8859-11"
118 #define CS_ISO_8859_13          "ISO-8859-13"
119 #define CS_ISO_8859_14          "ISO-8859-14"
120 #define CS_ISO_8859_15          "ISO-8859-15"
121 #define CS_BALTIC               "BALTIC"
122 #define CS_CP1250               "CP1250"
123 #define CS_CP1251               "CP1251"
124 #define CS_CP1252               "CP1252"
125 #define CS_CP1253               "CP1253"
126 #define CS_CP1254               "CP1254"
127 #define CS_CP1255               "CP1255"
128 #define CS_CP1256               "CP1256"
129 #define CS_CP1257               "CP1257"
130 #define CS_CP1258               "CP1258"
131 #define CS_WINDOWS_1250         "Windows-1250"
132 #define CS_WINDOWS_1251         "Windows-1251"
133 #define CS_WINDOWS_1252         "Windows-1252"
134 #define CS_WINDOWS_1253         "Windows-1253"
135 #define CS_WINDOWS_1254         "Windows-1254"
136 #define CS_WINDOWS_1255         "Windows-1255"
137 #define CS_WINDOWS_1256         "Windows-1256"
138 #define CS_WINDOWS_1257         "Windows-1257"
139 #define CS_WINDOWS_1258         "Windows-1258"
140 #define CS_KOI8_R               "KOI8-R"
141 #define CS_KOI8_T               "KOI8-T"
142 #define CS_KOI8_U               "KOI8-U"
143 #define CS_ISO_2022_JP          "ISO-2022-JP"
144 #define CS_ISO_2022_JP_2        "ISO-2022-JP-2"
145 #define CS_ISO_2022_JP_3        "ISO-2022-JP-3"
146 #define CS_EUC_JP               "EUC-JP"
147 #define CS_EUCJP                "EUCJP"
148 #define CS_SHIFT_JIS            "Shift_JIS"
149 #define CS_SHIFT__JIS           "SHIFT-JIS"
150 #define CS_SJIS                 "SJIS"
151 #define CS_X_SJIS               "X-SJIS"
152 #define CS_ISO_2022_KR          "ISO-2022-KR"
153 #define CS_EUC_KR               "EUC-KR"
154 #define CS_ISO_2022_CN          "ISO-2022-CN"
155 #define CS_EUC_CN               "EUC-CN"
156 #define CS_GB2312               "GB2312"
157 #define CS_GBK                  "GBK"
158 #define CS_EUC_TW               "EUC-TW"
159 #define CS_BIG5                 "Big5"
160 #define CS_BIG5_HKSCS           "BIG5-HKSCS"
161 #define CS_TIS_620              "TIS-620"
162 #define CS_WINDOWS_874          "Windows-874"
163 #define CS_GEORGIAN_PS          "GEORGIAN-PS"
164 #define CS_TCVN5712_1           "TCVN5712-1"
165
166 void conv_jistoeuc      (gchar *outbuf, gint outlen, const gchar *inbuf);
167 void conv_euctojis      (gchar *outbuf, gint outlen, const gchar *inbuf);
168 void conv_sjistoeuc     (gchar *outbuf, gint outlen, const gchar *inbuf);
169 void conv_anytoeuc      (gchar *outbuf, gint outlen, const gchar *inbuf);
170 void conv_anytoutf8     (gchar *outbuf, gint outlen, const gchar *inbuf);
171 void conv_anytojis      (gchar *outbuf, gint outlen, const gchar *inbuf);
172
173 void conv_unreadable_eucjp      (gchar *str);
174 void conv_unreadable_8bit       (gchar *str);
175 void conv_unreadable_latin      (gchar *str);
176 void conv_unreadable_locale     (gchar *str);
177
178 void conv_mb_alnum(gchar *str);
179
180 CharSet conv_guess_ja_encoding(const gchar *str);
181
182 void conv_jistodisp     (gchar *outbuf, gint outlen, const gchar *inbuf);
183 void conv_sjistodisp    (gchar *outbuf, gint outlen, const gchar *inbuf);
184 void conv_euctodisp     (gchar *outbuf, gint outlen, const gchar *inbuf);
185 void conv_ustodisp      (gchar *outbuf, gint outlen, const gchar *inbuf);
186 void conv_latintodisp   (gchar *outbuf, gint outlen, const gchar *inbuf);
187 void conv_noconv        (gchar *outbuf, gint outlen, const gchar *inbuf);
188 void conv_localetodisp  (gchar *outbuf, gint outlen, const gchar *inbuf);
189
190 CodeConverter *conv_code_converter_new  (const gchar    *charset);
191 void conv_code_converter_destroy        (CodeConverter  *conv);
192 gint conv_convert                       (CodeConverter  *conv,
193                                          gchar          *outbuf,
194                                          gint            outlen,
195                                          const gchar    *inbuf);
196
197 gchar *conv_codeset_strdup              (const gchar    *inbuf,
198                                          const gchar    *src_code,
199                                          const gchar    *dest_code);
200
201 CodeConvFunc conv_get_code_conv_func    (const gchar    *src_charset_str,
202                                          const gchar    *dest_charset_str);
203
204 gchar *conv_iconv_strdup                (const gchar    *inbuf,
205                                          const gchar    *src_code,
206                                          const gchar    *dest_code);
207
208 const gchar *conv_get_charset_str               (CharSet         charset);
209 CharSet conv_get_charset_from_str               (const gchar    *charset);
210 CharSet conv_get_current_charset                (void);
211 const gchar *conv_get_current_charset_str       (void);
212 CharSet conv_get_outgoing_charset               (void);
213 const gchar *conv_get_outgoing_charset_str      (void);
214 gboolean conv_is_multibyte_encoding             (CharSet         encoding);
215
216 const gchar *conv_get_current_locale            (void);
217
218 void conv_unmime_header_overwrite       (gchar          *str);
219 void conv_unmime_header                 (gchar          *outbuf,
220                                          gint            outlen,
221                                          const gchar    *str,
222                                          const gchar    *charset);
223 void conv_encode_header                 (gchar          *dest,
224                                          gint            len,
225                                          const gchar    *src,
226                                          gint            header_len,
227                                          gboolean        addr_field);
228
229
230 #endif /* __CODECONV_H__ */