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