23 #ifndef MUTT_LIB_CHARSET_H
24 #define MUTT_LIB_CHARSET_H
71 #define MUTT_ICONV_NO_FLAGS 0
72 #define MUTT_ICONV_HOOK_FROM 1
76 int mutt_ch_check(
const char *s,
size_t slen,
const char *from,
const char *to);
78 char *
mutt_ch_choose(
const char *fromcode,
const struct Slist *charsets,
const char *u,
size_t ulen,
char **d,
size_t *dlen);
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);
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")
bool mutt_ch_check_charset(const char *cs, bool strict)
Does iconv understand a character set?
void mutt_ch_fgetconv_close(struct FgetConv **fc)
Close an fgetconv handle.
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.
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
char * mutt_ch_get_langinfo_charset(void)
Get the user's choice of character set.
bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err)
Add a new character set lookup.
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
Canonicalise the charset of a string.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
struct FgetConv * mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, uint8_t flags)
Prepare a file for charset conversion.
LookupType
Types of character set lookups.
@ MUTT_LOOKUP_ICONV
Character set conversion.
@ MUTT_LOOKUP_CHARSET
Alias for another character set.
void mutt_ch_set_charset(const char *charset)
Update the records for a new character set.
bool CharsetIsUtf8
Is the user's current character set utf-8?
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.
int mutt_ch_fgetconv(struct FgetConv *fc)
Convert a file's character set.
const char * mutt_ch_charset_lookup(const char *chs)
Look for a replacement character set.
wchar_t ReplacementChar
When a Unicode character can't be displayed, use this instead.
char * mutt_ch_get_default_charset(void)
Get the default character set.
int mutt_ch_convert_nonmime_string(char **ps)
Try to convert a string using a list of character sets.
char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc)
Convert a file's charset into a string buffer.
const char * mutt_ch_iconv_lookup(const char *chs)
Look for a replacement character set.
bool mutt_ch_chscmp(const char *cs1, const char *cs2)
Are the names of two character sets equivalent?
iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, uint8_t flags)
Set up iconv for conversions.
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.
String manipulation buffer.
Cursor for converting a file's encoding.