blob: 2ab7c7cd798991ff6afa0225883ad6f8f1cadfed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "mbstring.h"
#include "unicode/prop.h"
#include "unicode/string.h"
size_t
u8casefold(char8_t *restrict dst, size_t dstn, struct u8view sv,
enum caseflags flags)
{
rune ch;
size_t n = 0;
while (u8next(&ch, &sv)) {
struct rview rv = uprop_get_cf(ch, flags & CF_LANG_AZ);
for (size_t i = 0; i < rv.len; i++) {
if (n >= dstn) {
char8_t buf[U8_LEN_MAX];
n += rtou8(buf, sizeof(buf), rv.p[i]);
} else
n += rtou8(dst + n, dstn - n, rv.p[i]);
}
}
return n;
}
|