aboutsummaryrefslogtreecommitdiff
path: root/vendor/librune/lib/utf8/u8chk.c
blob: 422bbd87581127a157d3c19f0b686052268f22d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "rune.h"
#include "utf8.h"

#include "internal/common.h"

const char8_t *
u8chk(const char8_t *s, size_t n)
{
	while (n) {
		rune ch;
		int m = u8tor(&ch, s);

		if (ch == RUNE_ERROR)
			return s;
		n -= m;
	}

	return nullptr;
}