Skip to contentSkip to conversation

client: better support utf-8 for table rows

PATCH Applied James Prestwood 2 participants 2 messages Oct 7, 2022 – Oct 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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(-)
client/display.c +3 -1
index 2b0fd4f7..b729ad4c 100644
@@ -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 */
Signature · 1 line
2.34.3
#1 lore raw

Hi James,

Quoted 6 lines · James Prestwood

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.

Quoted 6 lines

Fix this by increasing 'max' when non-codepoint utf-8 characters are found.

---
  client/display.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

Regards,
-Denis