NeoMutt  2021-02-05-666-ge300cd
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 <stdint.h>
29 #include <stdio.h>
30 #include <wchar.h>
31 
32 struct Buffer;
33 
34 extern bool CharsetIsUtf8;
35 extern wchar_t ReplacementChar;
36 
40 struct FgetConv
41 {
42  FILE *fp;
43  iconv_t cd;
44  char bufi[512];
45  char bufo[512];
46  char *p;
47  char *ob;
48  char *ib;
49  size_t ibl;
50  const char **inrepls;
51 };
52 
57 {
58  FILE *fp;
59  iconv_t cd;
60 };
61 
66 {
69 };
70 
71 #define MUTT_ICONV_NO_FLAGS 0
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, uint8_t 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, uint8_t 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, uint8_t 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 */
const char * mutt_ch_iconv_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:706
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
Definition: charset.c:521
iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, uint8_t flags)
Set up iconv for conversions.
Definition: charset.c:569
char bufi[512]
Definition: charset.h:44
iconv_t cd
Definition: charset.h:59
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:721
char * mutt_ch_get_langinfo_charset(void)
Get the user&#39;s choice of character set.
Definition: charset.c:466
bool mutt_ch_check_charset(const char *cs, bool strict)
Does iconv understand a character set?
Definition: charset.c:822
wchar_t ReplacementChar
When a Unicode character can&#39;t be displayed, use this instead.
Definition: charset.c:57
int mutt_ch_convert_nonmime_string(char **ps)
Try to convert a string using a list of character sets.
Definition: charset.c:308
String manipulation buffer.
Definition: buffer.h:33
char * mutt_ch_get_default_charset(void)
Get the default character set.
Definition: charset.c:442
Character set conversion.
Definition: charset.h:68
int mutt_ch_fgetconv(struct FgetConv *fc)
Convert a file&#39;s character set.
Definition: charset.c:912
size_t ibl
Definition: charset.h:49
static char * chs
Definition: gnupgparse.c:73
Alias for another character set.
Definition: charset.h:67
A dummy converter.
Definition: charset.h:56
FILE * fp
Definition: charset.h:42
iconv_t cd
Definition: charset.h:43
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:489
FILE * fp
Definition: charset.h:58
char * ib
Definition: charset.h:48
char * p
Definition: charset.h:46
char bufo[512]
Definition: charset.h:45
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
Canonicalise the charset of a string.
Definition: charset.c:354
struct FgetConv * mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, uint8_t flags)
Prepare a file for charset conversion.
Definition: charset.c:862
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:1040
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:974
bool mutt_ch_chscmp(const char *cs1, const char *cs2)
Are the names of two character sets equivalent?
Definition: charset.c:420
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition: charset.c:758
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:1007
bool CharsetIsUtf8
Is the user&#39;s current character set utf-8?
Definition: charset.c:62
Cursor for converting a file&#39;s encoding.
Definition: charset.h:40
LookupType
Types of character set lookups.
Definition: charset.h:65
char * ob
Definition: charset.h:47
const char ** inrepls
Definition: charset.h:50
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:622
void mutt_ch_fgetconv_close(struct FgetConv **fc)
Close an fgetconv handle.
Definition: charset.c:892
const char * mutt_ch_charset_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:542