harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit f674e4cac551546cfee5dc1521f6f013e6b44522
parent c3480506fea714cc9dff999329e33535f575127d
Author: Jose Lombera <jose@lombera.dev>
Date:   Sun, 11 Sep 2022 20:03:03 -0500

utf8: fix codepoint byte length decoding

Signed-off-by: Jose Lombera <jose@lombera.dev>

Diffstat:
Msrc/utf8.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/utf8.c b/src/utf8.c @@ -21,7 +21,7 @@ struct { { 0xF0, 0xE0, 3 }, { 0xF8, 0xF0, 4 }, { 0xFC, 0xF8, 5 }, - { 0xFE, 0xF8, 6 }, + { 0xFE, 0xFC, 6 }, { 0x80, 0x80, -1 }, }; @@ -99,7 +99,7 @@ int utf8_size(const char *s) { uint8_t c = (uint8_t)*s; - for (size_t i = 0; i < sizeof(sizes) / 2; ++i) { + for (size_t i = 0; i < sizeof(sizes) / sizeof(sizes[0]); ++i) { if ((c & sizes[i].mask) == sizes[i].result) { return sizes[i].octets; }