From 4bda4f3a769abfc42e862f67a3ef56481f48d4be Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 29 Sep 2026 00:06:01 +0200 Subject: [PATCH] fix(ui-new): keyboard letters were blank Since bf1e6fca kbApplyCapsUtf8 wanted 4 bytes free before each codepoint; the ABC grid passes a 3-byte cell buffer, so every cell came out empty (T9 and CardKB Compact draw no such cells, so it went unnoticed). A codepoint is now copied when it fits with the NUL. Co-Authored-By: Claude Opus 5.5 --- examples/companion_radio/ui-new/KeyboardWidget.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/ui-new/KeyboardWidget.h b/examples/companion_radio/ui-new/KeyboardWidget.h index bbc57b0b..4b8f23a7 100644 --- a/examples/companion_radio/ui-new/KeyboardWidget.h +++ b/examples/companion_radio/ui-new/KeyboardWidget.h @@ -159,12 +159,18 @@ static const int KB_PREVIEW_BYTES = KB_PREVIEW_CAP * 2; static void kbApplyCapsUtf8(const char* in, bool caps, char* out, size_t out_size) { size_t o = 0; const uint8_t* p = (const uint8_t*)in; - while (*p && o + 4 < out_size) { + while (*p) { uint32_t cp = DisplayDriver::decodeCodepoint(p); // Shared case table (ui-core/KeyboardData.h). ß stays ß here: its // uppercase ẞ (U+1E9E) is outside the misc-fixed font's U+0020-04FF. if (caps && cp != 0x00DF) cp = kbd::toUpper(cp); - o += kbd::encode(cp, out + o); + // Copied only if it fits with the NUL: a grid cell's buffer holds just one + // 2-byte letter, which a flat "4 bytes free" check left empty. + char enc[4]; + size_t n = kbd::encode(cp, enc); + if (o + n >= out_size) break; + memcpy(out + o, enc, n); + o += n; } out[o] = '\0'; }