NeoMutt  2023-03-22
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 <ctype.h>
28#include <stdbool.h>
29#include <wchar.h> // IWYU pragma: keep
30#include <wctype.h> // IWYU pragma: keep
31
32extern bool OptLocales;
33
34#ifdef LOCALES_HACK
35#define IsPrint(ch) (isprint((unsigned char) (ch)) || ((unsigned char) (ch) >= 0xa0))
36#define IsWPrint(wc) (iswprint(wc) || wc >= 0xa0)
37#else
38#define IsPrint(ch) (isprint((unsigned char) (ch)) || (OptLocales ? 0 : ((unsigned char) (ch) >= 0xa0)))
39#define IsWPrint(wc) (iswprint(wc) || (OptLocales ? 0 : (wc >= 0xa0)))
40#endif
41
42int mutt_mb_charlen(const char *s, int *width);
43int mutt_mb_filter_unprintable(char **s);
44bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen);
46bool mutt_mb_is_lower(const char *s);
47bool mutt_mb_is_shell_char(wchar_t ch);
48size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, const char *buf);
49void mutt_mb_wcstombs(char *dest, size_t dlen, const wchar_t *src, size_t slen);
50int mutt_mb_wcswidth(const wchar_t *s, size_t n);
51int mutt_mb_wcwidth(wchar_t wc);
52int mutt_mb_width(const char *str, int col, bool display);
53size_t mutt_mb_width_ceiling(const wchar_t *s, size_t n, int w1);
54
55#endif /* MUTT_LIB_MBYTE_H */
int mutt_mb_charlen(const char *s, int *width)
Count the bytes in a (multibyte) character.
Definition: mbyte.c:54
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:235
bool mutt_mb_is_shell_char(wchar_t ch)
Is character not typically part of a pathname.
Definition: mbyte.c:341
int mutt_mb_filter_unprintable(char **s)
Replace unprintable characters.
Definition: mbyte.c:421
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:215
bool OptLocales
(pseudo) set if user has valid locale definition
Definition: mbyte.c:43
bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen)
Turn a name into initials.
Definition: mbyte.c:82
bool mutt_mb_is_display_corrupting_utf8(wchar_t wc)
Will this character corrupt the display?
Definition: mbyte.c:387
size_t mutt_mb_mbstowcs(wchar_t **pwbuf, size_t *pwbuflen, size_t i, const char *buf)
Convert a string from multibyte to wide characters.
Definition: mbyte.c:292
int mutt_mb_width(const char *str, int col, bool display)
Measure a string's display width (in screen columns)
Definition: mbyte.c:137
int mutt_mb_wcswidth(const wchar_t *s, size_t n)
Measure the screen width of a string.
Definition: mbyte.c:194
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition: mbyte.c:355
int mutt_mb_wcwidth(wchar_t wc)
Measure the screen width of a character.
Definition: mbyte.c:176