NeoMutt  2019-11-11
Teaching an old dog new tricks
DOXYGEN
charset.h
Go to the documentation of this file.
1 
23 #ifndef MUTT_LIB_CHARSET_H
24 #define MUTT_LIB_CHARSET_H
25 
26 #include <iconv.h>
27 #include <stdbool.h>
28 #include <stdio.h>
29 #include <wchar.h>
30 
31 struct Buffer;
32 
33 extern char *C_AssumedCharset;
34 extern char *C_Charset;
35 extern bool CharsetIsUtf8;
36 extern wchar_t ReplacementChar;
37 
41 struct FgetConv
42 {
43  FILE *fp;
44  iconv_t cd;
45  char bufi[512];
46  char bufo[512];
47  char *p;
48  char *ob;
49  char *ib;
50  size_t ibl;
51  const char **inrepls;
52 };
53 
58 {
59  FILE *fp;
60  iconv_t cd;
61 };
62 
66 struct MimeNames
67 {
68  const char *key;
69  const char *pref;
70 };
71 
76 {
79 };
80 
81 #define MUTT_ICONV_HOOK_FROM 1
83 extern const struct MimeNames PreferredMimeNames[];
84 
85 void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name);
86 const char * mutt_ch_charset_lookup(const char *chs);
87 int mutt_ch_check(const char *s, size_t slen, const char *from, const char *to);
88 bool mutt_ch_check_charset(const char *cs, bool strict);
89 char * mutt_ch_choose(const char *fromcode, const char *charsets, const char *u, size_t ulen, char **d, size_t *dlen);
90 bool mutt_ch_chscmp(const char *cs1, const char *cs2);
91 int mutt_ch_convert_nonmime_string(char **ps);
92 int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags);
93 int mutt_ch_fgetconv(struct FgetConv *fc);
94 void mutt_ch_fgetconv_close(struct FgetConv **fc);
95 struct FgetConv *mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, int flags);
96 char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc);
97 char * mutt_ch_get_default_charset(void);
98 char * mutt_ch_get_langinfo_charset(void);
99 size_t mutt_ch_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, const char **inrepls, const char *outrepl, int *iconverrno);
100 const char * mutt_ch_iconv_lookup(const char *chs);
101 iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, int flags);
102 bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err);
103 void mutt_ch_lookup_remove(void);
104 void mutt_ch_set_charset(const char *charset);
105 
106 #define mutt_ch_is_utf8(str) mutt_ch_chscmp(str, "utf-8")
107 #define mutt_ch_is_us_ascii(str) mutt_ch_chscmp(str, "us-ascii")
108 
109 #endif /* MUTT_LIB_CHARSET_H */
Character set conversion.
Definition: charset.h:78
const char * key
Definition: charset.h:68
char bufi[512]
Definition: charset.h:45
iconv_t cd
Definition: charset.h:60
bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err)
Add a new character set lookup.
Definition: charset.c:479
char * C_AssumedCharset
Config: If a message is missing a character set, assume this character set.
Definition: charset.c:53
String manipulation buffer.
Definition: buffer.h:33
wchar_t ReplacementChar
When a Unicode character can&#39;t be displayed, use this instead.
Definition: charset.c:59
int mutt_ch_fgetconv(struct FgetConv *fc)
Convert a file&#39;s character set.
Definition: charset.c:902
char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc)
Convert a file&#39;s charset into a string buffer.
Definition: charset.c:964
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:997
int mutt_ch_convert_nonmime_string(char **ps)
Try to convert a string using a list of character sets.
Definition: charset.c:301
int mutt_ch_check(const char *s, size_t slen, const char *from, const char *to)
Check whether a string can be converted between encodings.
Definition: charset.c:711
size_t ibl
Definition: charset.h:50
const char * name
Definition: pgpmicalg.c:45
LookupType
Types of character set lookups.
Definition: charset.h:75
size_t mutt_ch_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, const char **inrepls, const char *outrepl, int *iconverrno)
Change the encoding of a string.
Definition: charset.c:612
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
Definition: charset.c:511
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
Canonicalise the charset of a string.
Definition: charset.c:345
static char * chs
Definition: gnupgparse.c:72
bool mutt_ch_chscmp(const char *cs1, const char *cs2)
Are the names of two character sets equivalent?
Definition: charset.c:412
A dummy converter.
Definition: charset.h:57
FILE * fp
Definition: charset.h:43
iconv_t cd
Definition: charset.h:44
char * mutt_ch_get_default_charset(void)
Get the default character set.
Definition: charset.c:434
char * mutt_ch_get_langinfo_charset(void)
Get the user&#39;s choice of character set.
Definition: charset.c:456
FILE * fp
Definition: charset.h:59
char * ib
Definition: charset.h:49
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags)
Convert a string between encodings.
Definition: charset.c:748
char * p
Definition: charset.h:47
iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, int flags)
Set up iconv for conversions.
Definition: charset.c:559
char * mutt_ch_choose(const char *fromcode, const char *charsets, const char *u, size_t ulen, char **d, size_t *dlen)
Figure the best charset to encode a string.
Definition: charset.c:1030
MIME name lookup entry.
Definition: charset.h:66
void mutt_ch_fgetconv_close(struct FgetConv **fc)
Close an fgetconv handle.
Definition: charset.c:882
char bufo[512]
Definition: charset.h:46
const char * pref
Definition: charset.h:69
struct FgetConv * mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, int flags)
Prepare a file for charset conversion.
Definition: charset.c:852
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
Cursor for converting a file&#39;s encoding.
Definition: charset.h:41
Alias for another character set.
Definition: charset.h:77
bool CharsetIsUtf8
Is the user&#39;s current character set utf-8?
Definition: charset.c:64
char * ob
Definition: charset.h:48
const char ** inrepls
Definition: charset.h:51
const char * mutt_ch_charset_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:532
const char * mutt_ch_iconv_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:696
bool mutt_ch_check_charset(const char *cs, bool strict)
Does iconv understand a character set?
Definition: charset.c:812