From 776b0b2b478d3bea21daada6a2cfb972a83f3ffb Mon Sep 17 00:00:00 2001 From: dzaima Date: Tue, 2 May 2023 10:48:53 +0300 Subject: [PATCH] fix estimated UTF-8 length of codepoints 2047 and 65535 --- src/utils/utf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utf.c b/src/utils/utf.c index 82fc8063..e44ec221 100644 --- a/src/utils/utf.c +++ b/src/utils/utf.c @@ -148,7 +148,7 @@ u64 utf8lenB(B x) { // doesn't consume; may error as it verifies whether is all u64 res = 0; for (usz i = 0; i < ia; i++) { u32 c = o2c(GetU(x,i)); - res+= c<128? 1 : c<0x07FF? 2 : c<0xFFFF? 3 : 4; + res+= c<=127? 1 : c<=0x07FF? 2 : c<=0xFFFF? 3 : 4; } return res; }