1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
/*
* LibSylph -- E-Mail client library
* Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __CODECONV_H__
#define __CODECONV_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h>
#include <iconv.h>
typedef struct _CodeConverter CodeConverter;
typedef enum
{
C_AUTO,
C_US_ASCII,
C_UTF_8,
C_UTF_7,
C_ISO_8859_1,
C_ISO_8859_2,
C_ISO_8859_3,
C_ISO_8859_4,
C_ISO_8859_5,
C_ISO_8859_6,
C_ISO_8859_7,
C_ISO_8859_8,
C_ISO_8859_9,
C_ISO_8859_10,
C_ISO_8859_11,
C_ISO_8859_13,
C_ISO_8859_14,
C_ISO_8859_15,
C_BALTIC,
C_CP932,
C_CP1250,
C_CP1251,
C_CP1252,
C_CP1253,
C_CP1254,
C_CP1255,
C_CP1256,
C_CP1257,
C_CP1258,
C_WINDOWS_932,
C_WINDOWS_1250,
C_WINDOWS_1251,
C_WINDOWS_1252,
C_WINDOWS_1253,
C_WINDOWS_1254,
C_WINDOWS_1255,
C_WINDOWS_1256,
C_WINDOWS_1257,
C_WINDOWS_1258,
C_KOI8_R,
C_KOI8_T,
C_KOI8_U,
C_ISO_2022_JP,
C_ISO_2022_JP_2,
C_ISO_2022_JP_3,
C_EUC_JP,
C_EUC_JP_MS,
C_SHIFT_JIS,
C_ISO_2022_KR,
C_EUC_KR,
C_ISO_2022_CN,
C_EUC_CN,
C_GB2312,
C_GBK,
C_EUC_TW,
C_BIG5,
C_BIG5_HKSCS,
C_TIS_620,
C_WINDOWS_874,
C_GEORGIAN_PS,
C_TCVN5712_1,
C_ISO_8859_16
} CharSet;
typedef enum
{
C_AD_BY_LOCALE,
C_AD_NEVER,
C_AD_JAPANESE
} ConvADType;
typedef gchar *(*CodeConvFunc) (const gchar *inbuf, gint *error);
struct _CodeConverter
{
CodeConvFunc code_conv_func;
gchar *src_encoding;
gchar *dest_encoding;
};
#define CS_AUTO "AUTO"
#define CS_US_ASCII "US-ASCII"
#define CS_ANSI_X3_4_1968 "ANSI_X3.4-1968"
#define CS_UTF_8 "UTF-8"
#define CS_UTF_7 "UTF-7"
#define CS_ISO_8859_1 "ISO-8859-1"
#define CS_ISO_8859_2 "ISO-8859-2"
#define CS_ISO_8859_3 "ISO-8859-3"
#define CS_ISO_8859_4 "ISO-8859-4"
#define CS_ISO_8859_5 "ISO-8859-5"
#define CS_ISO_8859_6 "ISO-8859-6"
#define CS_ISO_8859_7 "ISO-8859-7"
#define CS_ISO_8859_8 "ISO-8859-8"
#define CS_ISO_8859_9 "ISO-8859-9"
#define CS_ISO_8859_10 "ISO-8859-10"
#define CS_ISO_8859_11 "ISO-8859-11"
#define CS_ISO_8859_13 "ISO-8859-13"
#define CS_ISO_8859_14 "ISO-8859-14"
#define CS_ISO_8859_15 "ISO-8859-15"
#define CS_BALTIC "BALTIC"
#define CS_CP932 "CP932"
#define CS_CP1250 "CP1250"
#define CS_CP1251 "CP1251"
#define CS_CP1252 "CP1252"
#define CS_CP1253 "CP1253"
#define CS_CP1254 "CP1254"
#define CS_CP1255 "CP1255"
#define CS_CP1256 "CP1256"
#define CS_CP1257 "CP1257"
#define CS_CP1258 "CP1258"
#define CS_WINDOWS_932 "Windows-932"
#define CS_WINDOWS_1250 "Windows-1250"
#define CS_WINDOWS_1251 "Windows-1251"
#define CS_WINDOWS_1252 "Windows-1252"
#define CS_WINDOWS_1253 "Windows-1253"
#define CS_WINDOWS_1254 "Windows-1254"
#define CS_WINDOWS_1255 "Windows-1255"
#define CS_WINDOWS_1256 "Windows-1256"
#define CS_WINDOWS_1257 "Windows-1257"
#define CS_WINDOWS_1258 "Windows-1258"
#define CS_KOI8_R "KOI8-R"
#define CS_KOI8_T "KOI8-T"
#define CS_KOI8_U "KOI8-U"
#define CS_ISO_2022_JP "ISO-2022-JP"
#define CS_ISO_2022_JP_2 "ISO-2022-JP-2"
#define CS_ISO_2022_JP_3 "ISO-2022-JP-3"
#define CS_EUC_JP "EUC-JP"
#define CS_EUCJP "EUCJP"
#define CS_EUC_JP_MS "EUC-JP-MS"
#define CS_SHIFT_JIS "Shift_JIS"
#define CS_SHIFT__JIS "SHIFT-JIS"
#define CS_SJIS "SJIS"
#define CS_X_SJIS "X-SJIS"
#define CS_ISO_2022_KR "ISO-2022-KR"
#define CS_EUC_KR "EUC-KR"
#define CS_KS_C_5601_1987 "ks_c_5601-1987"
#define CS_ISO_2022_CN "ISO-2022-CN"
#define CS_EUC_CN "EUC-CN"
#define CS_GB2312 "GB2312"
#define CS_GBK "GBK"
#define CS_X_GBK "X-GBK"
#define CS_EUC_TW "EUC-TW"
#define CS_BIG5 "Big5"
#define CS_BIG5_HKSCS "BIG5-HKSCS"
#define CS_TIS_620 "TIS-620"
#define CS_WINDOWS_874 "Windows-874"
#define CS_GEORGIAN_PS "GEORGIAN-PS"
#define CS_TCVN5712_1 "TCVN5712-1"
#define CS_ISO_8859_16 "ISO-8859-16"
#define C_INTERNAL C_UTF_8
#define CS_INTERNAL CS_UTF_8
//void conv_mb_alnum(gchar *str);
CharSet conv_guess_ja_encoding (const gchar *str);
gchar *conv_utf8todisp (const gchar *inbuf,
gint *error);
gchar *conv_localetodisp (const gchar *inbuf,
gint *error);
CodeConverter *conv_code_converter_new (const gchar *src_encoding,
const gchar *dest_encoding);
void conv_code_converter_destroy (CodeConverter *conv);
gchar *conv_convert (CodeConverter *conv,
const gchar *inbuf);
#define conv_codeset_strdup(inbuf, src_code, dest_code) \
(conv_codeset_strdup_full(inbuf, src_code, dest_code, NULL))
gchar *conv_codeset_strdup_full (const gchar *inbuf,
const gchar *src_encoding,
const gchar *dest_encoding,
gint *error);
CodeConvFunc conv_get_code_conv_func (const gchar *src_encoding,
const gchar *dest_encoding);
gchar *conv_iconv_strdup (const gchar *inbuf,
const gchar *src_encoding,
const gchar *dest_encoding,
gint *error);
gchar *conv_iconv_strdup_with_cd (const gchar *inbuf,
iconv_t cd,
gint *error);
const gchar *conv_get_charset_str (CharSet charset);
CharSet conv_get_charset_from_str (const gchar *charset);
CharSet conv_get_locale_charset (void);
const gchar *conv_get_locale_charset_str (void);
CharSet conv_get_internal_charset (void);
const gchar *conv_get_internal_charset_str (void);
CharSet conv_get_outgoing_charset (void);
const gchar *conv_get_outgoing_charset_str (void);
gboolean conv_is_multibyte_encoding (CharSet encoding);
const gchar *conv_get_current_locale (void);
gboolean conv_is_ja_locale (void);
void conv_set_autodetect_type (ConvADType type);
ConvADType conv_get_autodetect_type (void);
gchar *conv_unmime_header (const gchar *str,
const gchar *default_encoding);
void conv_encode_header (gchar *dest,
gint len,
const gchar *src,
gint header_len,
gboolean addr_field,
const gchar *out_encoding);
gchar *conv_encode_filename (const gchar *src,
const gchar *param_name,
const gchar *out_encoding);
gint conv_copy_file (const gchar *src,
const gchar *dest,
const gchar *src_encoding);
gint conv_copy_dir (const gchar *src,
const gchar *dest,
const gchar *src_encoding);
CharSet conv_check_file_encoding (const gchar *file);
gchar *conv_filename_from_utf8 (const gchar *utf8_file);
gchar *conv_filename_to_utf8 (const gchar *fs_file);
#endif /* __CODECONV_H__ */
|