56 if (!s || (*s ==
'\0'))
60 mbstate_t mbstate = { 0 };
63 size_t k = mbrtowc(&wc, s, n, &mbstate);
94 if ((clen == 1) && ispunct(*name))
109 for (; *name; name += clen)
114 if ((clen == 1) && (isspace(*name) || (*name ==
'-')))
119 while (*name && (isspace(*name) || (*name ==
'-')))
143 mbstate_t mbstate = { 0 };
147 while (*str && (str_len > 0))
150 size_t consumed = mbrtowc(&wc, str, str_len, &mbstate);
156 memset(&mbstate, 0,
sizeof(mbstate));
166 int wchar_width = wcwidth(wc);
170 if ((wc == L
'\t') || (nl && (wc == L
' ')))
175 wchar_width = 8 - (col % 8);
177 else if (indent && (wc ==
'\n'))
184 total_width += wchar_width;
241 const wchar_t *s0 = s;
263 mbstate_t mbstate = { 0 };
266 char *buf = dest->
data;
267 size_t buflen = dest->
dsize;
269 for (; (wlen > 0) && (buflen >= MB_LEN_MAX); buf += k, buflen -= k, wstr++, wlen--)
271 k = wcrtomb(buf, *wstr, &mbstate);
292 if (!pwbuf || !pwbuflen || !buf)
296 mbstate_t mbstate = { 0 };
298 wchar_t *wbuf = *pwbuf;
299 size_t wbuflen = *pwbuflen;
303 memset(&mbstate, 0,
sizeof(mbstate));
304 for (; (k = mbrtowc(&wc, buf, MB_LEN_MAX, &mbstate)) &&
341 static const wchar_t shell_chars[] = L
"<>&()$?*;{}| ";
342 return wcschr(shell_chars, ch);
359 mbstate_t mbstate = { 0 };
362 memset(&mbstate, 0,
sizeof(mbstate));
364 for (; (l = mbrtowc(&wc, s, MB_CUR_MAX, &mbstate)) != 0; s += 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))
426 char scratch[MB_LEN_MAX + 1];
428 mbstate_t mbstate1 = { 0 };
429 mbstate_t mbstate2 = { 0 };
432 for (; (k = mbrtowc(&wc, p, MB_LEN_MAX, &mbstate1)); p += k)
437 memset(&mbstate1, 0,
sizeof(mbstate1));
444 k2 = wcrtomb(scratch, wc, &mbstate2);
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
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.
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.
String manipulation functions.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.