NeoMutt  2022-04-29-249-gaae397
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 <wchar.h>
30
31struct Buffer;
32struct Slist;
33
34extern bool CharsetIsUtf8;
35extern wchar_t ReplacementChar;
36
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
74void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name);
75const char * mutt_ch_charset_lookup(const char *chs);
76int mutt_ch_check(const char *s, size_t slen, const char *from, const char *to);
77bool mutt_ch_check_charset(const char *cs, bool strict);
78char * mutt_ch_choose(const char *fromcode, const struct Slist *charsets, const char *u, size_t ulen, char **d, size_t *dlen);
79bool mutt_ch_chscmp(const char *cs1, const char *cs2);
81int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags);
82int mutt_ch_fgetconv(struct FgetConv *fc);
83void mutt_ch_fgetconv_close(struct FgetConv **fc);
84struct FgetConv *mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, uint8_t flags);
85char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc);
88size_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);
89const char * mutt_ch_iconv_lookup(const char *chs);
90iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, uint8_t flags);
91bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err);
92void mutt_ch_lookup_remove(void);
93void 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 */
static char * chs
Definition: gnupgparse.c:73
bool mutt_ch_check_charset(const char *cs, bool strict)
Does iconv understand a character set?
Definition: charset.c:817
void mutt_ch_fgetconv_close(struct FgetConv **fc)
Close an fgetconv handle.
Definition: charset.c:887
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:617
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
Definition: charset.c:516
char * mutt_ch_choose(const char *fromcode, const struct Slist *charsets, const char *u, size_t ulen, char **d, size_t *dlen)
Figure the best charset to encode a string.
Definition: charset.c:1035
char * mutt_ch_get_langinfo_charset(void)
Get the user's choice of character set.
Definition: charset.c:461
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:484
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
Canonicalise the charset of a string.
Definition: charset.c:351
const char * mutt_ch_iconv_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:701
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition: charset.c:752
LookupType
Types of character set lookups.
Definition: charset.h:66
@ MUTT_LOOKUP_ICONV
Character set conversion.
Definition: charset.h:68
@ MUTT_LOOKUP_CHARSET
Alias for another character set.
Definition: charset.h:67
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
Definition: charset.c:1002
bool CharsetIsUtf8
Is the user's current character set utf-8?
Definition: charset.c:62
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:716
const char * mutt_ch_charset_lookup(const char *chs)
Look for a replacement character set.
Definition: charset.c:537
char * mutt_ch_get_default_charset(void)
Get the default character set.
Definition: charset.c:439
int mutt_ch_fgetconv(struct FgetConv *fc)
Convert a file's character set.
Definition: charset.c:907
wchar_t ReplacementChar
When a Unicode character can'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:307
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:857
char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc)
Convert a file's charset into a string buffer.
Definition: charset.c:969
bool mutt_ch_chscmp(const char *cs1, const char *cs2)
Are the names of two character sets equivalent?
Definition: charset.c:417
iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, uint8_t flags)
Set up iconv for conversions.
Definition: charset.c:564
String manipulation buffer.
Definition: buffer.h:34
A dummy converter.
Definition: charset.h:57
FILE * fp
Definition: charset.h:58
iconv_t cd
Definition: charset.h:59
Cursor for converting a file's encoding.
Definition: charset.h:41
char bufi[512]
Definition: charset.h:44
iconv_t cd
Definition: charset.h:43
char bufo[512]
Definition: charset.h:45
size_t ibl
Definition: charset.h:49
FILE * fp
Definition: charset.h:42
char * p
Definition: charset.h:46
const char ** inrepls
Definition: charset.h:50
char * ib
Definition: charset.h:48
char * ob
Definition: charset.h:47
String list.
Definition: slist.h:47