NeoMutt  2020-08-07-1-gab41a1
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 
67 {
70 };
71 
72 #define MUTT_ICONV_HOOK_FROM 1
73 
74 void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name);
75 const char * mutt_ch_charset_lookup(const char *chs);
76 int mutt_ch_check(const char *s, size_t slen, const char *from, const char *to);
77 bool mutt_ch_check_charset(const char *cs, bool strict);
78 char * mutt_ch_choose(const char *fromcode, const char *charsets, const char *u, size_t ulen, char **d, size_t *dlen);
79 bool mutt_ch_chscmp(const char *cs1, const char *cs2);
80 int mutt_ch_convert_nonmime_string(char **ps);
81 int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags);
82 int mutt_ch_fgetconv(struct FgetConv *fc);
83 void mutt_ch_fgetconv_close(struct FgetConv **fc);
84 struct FgetConv *mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, int flags);
85 char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc);
86 char * mutt_ch_get_default_charset(void);
87 char * mutt_ch_get_langinfo_charset(void);
88 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);
89 const char * mutt_ch_iconv_lookup(const char *chs);
90 iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, int flags);
91 bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err);
92 void mutt_ch_lookup_remove(void);
93 void mutt_ch_set_charset(const char *charset);
94 
95 #define mutt_ch_is_utf8(str) mutt_ch_chscmp(str, "utf-8")
96 #define mutt_ch_is_us_ascii(str) mutt_ch_chscmp(str, "us-ascii")
97 
98 #endif /* MUTT_LIB_CHARSET_H */
Character set conversion.
Definition: charset.h:69
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:485
char * C_AssumedCharset
Config: If a message is missing a character set, assume this character set.
Definition: charset.c:52
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:58
int mutt_ch_fgetconv(struct FgetConv *fc)
Convert a file&#39;s character set.
Definition: charset.c:908
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:970
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:1003
int mutt_ch_convert_nonmime_string(char **ps)
Try to convert a string using a list of character sets.
Definition: charset.c:309
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:717
size_t ibl
Definition: charset.h:50
LookupType
Types of character set lookups.
Definition: charset.h:66
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:618
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
Definition: charset.c:517
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
Canonicalise the charset of a string.
Definition: charset.c:352
static char * chs
Definition: gnupgparse.c:73
bool mutt_ch_chscmp(const char *cs1, const char *cs2)
Are the names of two character sets equivalent?
Definition: charset.c:418
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:440
char * mutt_ch_get_langinfo_charset(void)
Get the user&#39;s choice of character set.
Definition: charset.c:462
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:754
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:565
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:1036
void mutt_ch_fgetconv_close(struct FgetConv **fc)
Close an fgetconv handle.
Definition: charset.c:888
char bufo[512]
Definition: charset.h:46
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:858
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:53
Cursor for converting a file&#39;s encoding.
Definition: charset.h:41
Alias for another character set.
Definition: charset.h:68
bool CharsetIsUtf8
Is the user&#39;s current character set utf-8?
Definition: charset.c:63
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:538
const char * mutt_ch_iconv_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:702
bool mutt_ch_check_charset(const char *cs, bool strict)
Does iconv understand a character set?
Definition: charset.c:818