1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-08 18:09:45 +01:00

Fix UTF-8 handling in next_wrap

Finally this FIXME can be removed!
This commit is contained in:
Dav999-v 2023-02-23 04:52:56 +01:00 committed by Misa Elizabeth Kai
parent b02e4737d4
commit a91c85d92e

View file

@ -789,14 +789,10 @@ static bool next_wrap(
while (true) while (true)
{ {
/* FIXME: This only checks one byte, not multiple! */ uint8_t codepoint_nbytes;
if ((str[idx] & 0xC0) == 0x80) uint32_t codepoint = UTF8_peek_next(&str[idx], &codepoint_nbytes);
{
/* Skip continuation byte. */
goto next;
}
switch (str[idx]) switch (codepoint)
{ {
case ' ': case ' ':
if (loc::get_langmeta()->autowordwrap) if (loc::get_langmeta()->autowordwrap)
@ -813,7 +809,7 @@ static bool next_wrap(
return true; return true;
} }
linewidth += get_advance(f, str[idx]); linewidth += get_advance(f, codepoint);
if (linewidth > maxwidth) if (linewidth > maxwidth)
{ {
@ -831,10 +827,9 @@ static bool next_wrap(
return true; return true;
} }
next: idx += codepoint_nbytes;
idx += 1; *start += codepoint_nbytes;
*start += 1; *len += codepoint_nbytes;
*len += 1;
} }
} }