sbase/libutf/utftorunestr.c
Richard Ipsum 2f0b15201d paste: Support -d '\0'
POSIX specifies that -d '\0' sets the delimiter to an empty string.
2020-04-15 16:11:12 -07:00

28 lines
427 B
C

/* See LICENSE file for copyright and license details. */
#include "../utf.h"
size_t
utftorunestr(const char *str, Rune *r)
{
size_t i;
int n;
for (i = 0; (n = chartorune(&r[i], str)) && r[i]; i++)
str += n;
return i;
}
size_t
utfntorunestr(const char *str, size_t len, Rune *r)
{
size_t i;
int n;
const char *end = str + len;
for (i = 0; (n = charntorune(&r[i], str, end - str)); i++)
str += n;
return i;
}