workaround crash when rendering some utf8 on win32 gui

closes #194

Ignores cells that have graphemes with more than 1 codepoint rather than
crash.
This commit is contained in:
Jonathan Marler 2025-09-23 14:04:58 -06:00 committed by CJ van den Berg
parent 2790dcfd11
commit 921f094509

View file

@ -1086,7 +1086,10 @@ fn WndProc(
var prev_codepoint: u21 = undefined; var prev_codepoint: u21 = undefined;
for (global.screen.buf, global.render_cells.items) |*screen_cell, *render_cell| { for (global.screen.buf, global.render_cells.items) |*screen_cell, *render_cell| {
const width = screen_cell.char.width; const width = screen_cell.char.width;
const codepoint = if (std.unicode.utf8ValidateSlice(screen_cell.char.grapheme)) // temporary workaround, ignore multi-codepoint graphemes
const codepoint = if (screen_cell.char.grapheme.len > 4)
std.unicode.replacement_character
else if (std.unicode.utf8ValidateSlice(screen_cell.char.grapheme))
std.unicode.wtf8Decode(screen_cell.char.grapheme) catch std.unicode.replacement_character std.unicode.wtf8Decode(screen_cell.char.grapheme) catch std.unicode.replacement_character
else else
std.unicode.replacement_character; std.unicode.replacement_character;