58 if (!s || (*s ==
'\0'))
62 mbstate_t mbstate = { 0 };
65 size_t k = mbrtowc(&wc, s, n, &mbstate);
111 for (; *name; name += clen)
116 if ((clen == 1) && (
mutt_isspace(*name) || (*name ==
'-')))
121 while (*name && (
mutt_isspace(*name) || (*name ==
'-')))
145 mbstate_t mbstate = { 0 };
149 while (*str && (str_len > 0))
152 size_t consumed = mbrtowc(&wc, str, str_len, &mbstate);
158 memset(&mbstate, 0,
sizeof(mbstate));
168 int wchar_width = wcwidth(wc);
172 if ((wc == L
'\t') || (nl && (wc == L
' ')))
177 wchar_width = 8 - (col % 8);
179 else if (indent && (wc ==
'\n'))
186 total_width += wchar_width;
243 const wchar_t *s0 = s;
265 mbstate_t mbstate = { 0 };
268 char *buf = dest->
data;
269 size_t buflen = dest->
dsize;
271 for (; (wlen > 0) && (buflen >= MB_LEN_MAX); buf += k, buflen -= k, wstr++, wlen--)
273 k = wcrtomb(buf, *wstr, &mbstate);
294 if (!pwbuf || !pwbuflen || !buf)
298 mbstate_t mbstate = { 0 };
300 wchar_t *wbuf = *pwbuf;
301 size_t wbuflen = *pwbuflen;
305 memset(&mbstate, 0,
sizeof(mbstate));
306 for (; (k = mbrtowc(&wc, buf, MB_LEN_MAX, &mbstate)) &&
343 static const wchar_t shell_chars[] = L
"<>&()$?*;{}| ";
344 return wcschr(shell_chars, ch);
361 mbstate_t mbstate = { 0 };
364 memset(&mbstate, 0,
sizeof(mbstate));
367 for (; (n > 0) && (*s !=
'\0') && (l = mbrtowc(&wc, s, n, &mbstate)) != 0; s += l, n -= l)
371 if (iswalpha((wint_t) wc) && iswupper((wint_t) wc))
388 if ((wc == (
wchar_t) 0x00ad) ||
389 (wc == (
wchar_t) 0x200e) ||
390 (wc == (
wchar_t) 0x200f) ||
391 (wc == (
wchar_t) 0xfeff))
398 if ((wc >= (
wchar_t) 0x2066) && (wc <= (
wchar_t) 0x2069))
403 if ((wc >= (
wchar_t) 0x202a) && (wc <= (
wchar_t) 0x202e))
407 if (wc == (
wchar_t) 0x061c)
431 char scratch[MB_LEN_MAX + 1];
433 mbstate_t mbstate1 = { 0 };
434 mbstate_t mbstate2 = { 0 };
437 for (; (k = mbrtowc(&wc, p, MB_LEN_MAX, &mbstate1)); p += k)
442 memset(&mbstate1, 0,
sizeof(mbstate1));
453 k2 = wcrtomb(scratch, wc, &mbstate2);
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
General purpose object for storing and parsing strings.
ctype(3) wrapper functions
bool mutt_isspace(int arg)
Wrapper for isspace(3)
bool mutt_ispunct(int arg)
Wrapper for ispunct(3)
int mutt_mb_charlen(const char *s, int *width)
Count the bytes in a (multibyte) character.
bool mutt_mb_is_shell_char(wchar_t ch)
Is character not typically part of a pathname.
int mutt_mb_filter_unprintable(char **s)
Replace unprintable characters.
size_t mutt_mb_width_ceiling(const wchar_t *s, size_t n, int w1)
Keep the end of the string on-screen.
bool OptLocales
(pseudo) set if user has valid locale definition
bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen)
Turn a name into initials.
bool mutt_mb_is_display_corrupting_utf8(wchar_t wc)
Will this character corrupt the display?
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.
int mutt_mb_wcswidth(const wchar_t *s, size_t n)
Measure the screen width of a string.
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
int mutt_mb_width(const char *str, int col, bool indent)
Measure a string's display width (in screen columns)
void buf_mb_wcstombs(struct Buffer *dest, const wchar_t *wstr, size_t wlen)
Convert a string from wide to multibyte characters.
int mutt_mb_wcwidth(wchar_t wc)
Measure the screen width of a character.
Multi-byte String manipulation functions.
Memory management wrappers.
#define FREE(x)
Free memory and set the pointer to NULL.
#define MUTT_MEM_CALLOC(n, type)
#define MUTT_MEM_REALLOC(pptr, n, type)
bool CharsetIsUtf8
Is the user's current character set utf-8?
wchar_t ReplacementChar
When a Unicode character can't be displayed, use this instead.
Conversion between different character encodings.
#define ICONV_BUF_TOO_SMALL
Error value for iconv() - Buffer too small.
#define ICONV_ILLEGAL_SEQ
Error value for iconv() - Illegal sequence.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
A global pool of Buffers.
String manipulation functions.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.