NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
mbyte.h
Go to the documentation of this file.
1 
23 #ifndef MUTT_LIB_MBYTE_H
24 #define MUTT_LIB_MBYTE_H
25 
26 #include "config.h"
27 #include <stddef.h>
28 #include <ctype.h>
29 #include <stdbool.h>
30 #include <wchar.h>
31 #include <wctype.h> // IWYU pragma: keep
32 
33 extern bool OptLocales;
34 
35 #ifdef LOCALES_HACK
36 #define IsPrint(ch) (isprint((unsigned char) (ch)) || ((unsigned char) (ch) >= 0xa0))
37 #define IsWPrint(wc) (iswprint(wc) || wc >= 0xa0)
38 #else
39 #define IsPrint(ch) (isprint((unsigned char) (ch)) || (OptLocales ? 0 : ((unsigned char) (ch) >= 0xa0)))
40 #define IsWPrint(wc) (iswprint(wc) || (OptLocales ? 0 : (wc >= 0xa0)))
41 #endif
42 
43 int mutt_mb_charlen(const char *s, int *width);
44 int mutt_mb_filter_unprintable(char **s);
45 bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen);
46 bool mutt_mb_is_display_corrupting_utf8(wchar_t wc);
47 bool mutt_mb_is_lower(const char *s);
48 bool mutt_mb_is_shell_char(wchar_t ch);
49 size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf);
50 void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen);
51 int mutt_mb_wcswidth(const wchar_t *s, size_t n);
52 int mutt_mb_wcwidth(wchar_t wc);
53 int mutt_mb_width(const char *str, int col, bool display);
54 size_t mutt_mb_width_ceiling(const wchar_t *s, size_t n, int w1);
55 
56 #endif /* MUTT_LIB_MBYTE_H */
int mutt_mb_charlen(const char *s, int *width)
Count the bytes in a (multibyte) character.
Definition: mbyte.c:55
int mutt_mb_wcwidth(wchar_t wc)
Measure the screen width of a character.
Definition: mbyte.c:178
int mutt_mb_width(const char *str, int col, bool display)
Measure a string&#39;s display width (in screen columns)
Definition: mbyte.c:139
size_t mutt_mb_width_ceiling(const wchar_t *s, size_t n, int w1)
Keep the end of the string on-screen.
Definition: mbyte.c:217
bool mutt_mb_is_display_corrupting_utf8(wchar_t wc)
Will this character corrupt the display?
Definition: mbyte.c:390
void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen)
Convert a string from wide to multibyte characters.
Definition: mbyte.c:237
bool OptLocales
(pseudo) set if user has valid locale definition
Definition: mbyte.c:44
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition: mbyte.c:358
bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen)
Turn a name into initials.
Definition: mbyte.c:84
bool mutt_mb_is_shell_char(wchar_t ch)
Is character not typically part of a pathname.
Definition: mbyte.c:344
size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, char *buf)
Convert a string from multibyte to wide characters.
Definition: mbyte.c:295
int mutt_mb_filter_unprintable(char **s)
Replace unprintable characters.
Definition: mbyte.c:424
int mutt_mb_wcswidth(const wchar_t *s, size_t n)
Measure the screen width of a string.
Definition: mbyte.c:196