57 if (!s || (*s ==
'\0'))
61 mbstate_t mbstate = { 0 };
64 size_t k = mbrtowc(&wc, s, n, &mbstate);
95 if ((clen == 1) && ispunct(*name))
110 for (; *name; name += clen)
115 if ((clen == 1) && (isspace(*name) || (*name ==
'-')))
120 while (*name && (isspace(*name) || (*name ==
'-')))
144 mbstate_t mbstate = { 0 };
148 while (*str && (str_len > 0))
151 size_t consumed = mbrtowc(&wc, str, str_len, &mbstate);
157 memset(&mbstate, 0,
sizeof(mbstate));
167 int wchar_width = wcwidth(wc);
171 if ((wc == L
'\t') || (nl && (wc == L
' ')))
176 wchar_width = 8 - (col % 8);
178 else if (indent && (wc ==
'\n'))
185 total_width += wchar_width;
242 const wchar_t *s0 = s;
264 mbstate_t mbstate = { 0 };
267 char *buf = dest->
data;
268 size_t buflen = dest->
dsize;
270 for (; (wlen > 0) && (buflen >= MB_LEN_MAX); buf += k, buflen -= k, wstr++, wlen--)
272 k = wcrtomb(buf, *wstr, &mbstate);
293 if (!pwbuf || !pwbuflen || !buf)
297 mbstate_t mbstate = { 0 };
299 wchar_t *wbuf = *pwbuf;
300 size_t wbuflen = *pwbuflen;
304 memset(&mbstate, 0,
sizeof(mbstate));
305 for (; (k = mbrtowc(&wc, buf, MB_LEN_MAX, &mbstate)) &&
342 static const wchar_t shell_chars[] = L
"<>&()$?*;{}| ";
343 return wcschr(shell_chars, ch);
360 mbstate_t mbstate = { 0 };
363 memset(&mbstate, 0,
sizeof(mbstate));
366 for (; (n > 0) && (*s !=
'\0') && (l = mbrtowc(&wc, s, n, &mbstate)) != 0; s += l, n -= l)
370 if (iswalpha((wint_t) wc) && iswupper((wint_t) wc))
387 if ((wc == (
wchar_t) 0x00ad) ||
388 (wc == (
wchar_t) 0x200e) ||
389 (wc == (
wchar_t) 0x200f) ||
390 (wc == (
wchar_t) 0xfeff))
397 if ((wc >= (
wchar_t) 0x2066) && (wc <= (
wchar_t) 0x2069))
402 if ((wc >= (
wchar_t) 0x202a) && (wc <= (
wchar_t) 0x202e))
406 if (wc == (
wchar_t) 0x061c)
430 char scratch[MB_LEN_MAX + 1];
432 mbstate_t mbstate1 = { 0 };
433 mbstate_t mbstate2 = { 0 };
436 for (; (k = mbrtowc(&wc, p, MB_LEN_MAX, &mbstate1)); p += k)
441 memset(&mbstate1, 0,
sizeof(mbstate1));
448 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.
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.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Memory management wrappers.
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.