From f9b7e32c2d6d3b6f13f73e2e127b11686daa7546 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 7 Oct 2022 12:59:37 -0700 Subject: [PATCH] client: better support utf-8 for table rows The utf-8 bytes were being counted as normal ascii so the width maximum was not being increased to include non-printable bytes like it is for color escape sequences. This lead to the row not printing enough characters which effected the text further down the line. Fix this by increasing 'max' when non-codepoint utf-8 characters are found. --- client/display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/display.c b/client/display.c index 2b0fd4f7..b729ad4c 100644 --- a/client/display.c +++ b/client/display.c @@ -410,7 +410,9 @@ static char* next_line(char *s, unsigned int *max, char **color_out) /* color escape won't count for column width */ *max += color_end(s + i); last_color = i; - } + /* Add width for non-codepoint UTF-8 bytes */ + } else if (((uint8_t)s[i] >> 6) == 2) + *max += 1; } /* Reached the end of the string within the column bounds */