From 0a25a86c098a2a06d8f6948bdb074e2bc0dcaf4e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 15 Oct 2022 14:07:17 +0200 Subject: Properly handle backspace characters --- center.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/center.c b/center.c index 7ac5d69..61193a1 100644 --- a/center.c +++ b/center.c @@ -230,8 +230,8 @@ utf8len(const char *s) { int l = 0; - while (*s) - l += (*s++ & 0xC0) != 0x80; + for (; *s; s++) + l += *s == '\b' ? -1 : (*s & 0xC0) != 0x80; if (l > 0 && s[-1] == '\n') l--; -- cgit v1.2.3