b27a5c6c9aad71ca8c26750704bf17a2c80cf167
[apps/madmutt.git] / charset.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #ifndef _CHARSET_H
11 #define _CHARSET_H
12
13 #ifdef HAVE_CONFIG_H
14 #  include "config.h"
15 #endif
16
17
18 #define M_ICONV_HOOK_FROM 1
19 #define M_ICONV_HOOK_TO   2
20
21 extern char *Charset;
22 extern int Charset_is_utf8;
23
24 void charset_initialize(void);
25 void mutt_canonical_charset(char *, ssize_t, const char *);
26
27 int charset_is_utf8(const char *s);
28 int charset_is_us_ascii(const char *s);
29
30 #ifdef HAVE_ICONV_H
31 #  include <iconv.h>
32
33 static inline ssize_t
34 my_iconv(iconv_t ict, const char **in, ssize_t *il, char **out, ssize_t *ol) {
35     return iconv(ict, (char **)in, (size_t*)il, out, (size_t*)ol);
36 }
37
38 #else
39 #  define iconv_t              void*
40 #  define iconv_open(a, b)     ((iconv_t)(-1))
41 #  define my_iconv(a,b,c,d,e)  0
42 #  define iconv_close(a)       0
43 #endif
44
45 int mutt_convert_string (char **, const char *, const char *, int);
46 const char *mutt_get_first_charset (const char *);
47 int mutt_convert_nonmime_string (char **);
48
49 iconv_t mutt_iconv_open (const char *, const char *, int);
50 ssize_t mutt_iconv (iconv_t, const char **, ssize_t *, char **, ssize_t *,
51                     const char **, const char *);
52
53 typedef void *FGETCONV;
54
55 FGETCONV *fgetconv_open (FILE *, const char *, const char *, int);
56 int fgetconv (FGETCONV *);
57 char *fgetconvs (char *, ssize_t, FGETCONV *);
58 void fgetconv_close (FGETCONV **);
59
60 wchar_t replacement_char(void);
61
62 #endif /* _CHARSET_H */