fix estimated UTF-8 length of codepoints 2047 and 65535

This commit is contained in:
dzaima 2023-05-02 10:48:53 +03:00
parent 352961a7eb
commit 776b0b2b47

View File

@ -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;
}