commit 0513b91be1173b1ed43a0f1d28cf502a81267185
parent 71ececc4f264eed36f022b4b52c9100b9e7b1b12
Author: René Wagner <rwagner@rw-net.de>
Date: Mon, 4 Jan 2021 13:08:11 +0100
fix premature line wraps
caused by multibyte unicode characters.
During column count unicode continuation bytes
are not counted as columns.
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/gmnlm.c b/src/gmnlm.c
@@ -730,6 +730,9 @@ wrap(FILE *f, char *s, struct winsize *ws, int *row, int *col)
if (!s[i+1]) break;
/* fallthrough */
default:
+ // skip unicode continuation bytes
+ if ((s[i] & 0xc0) == 0x80) break;
+
if (iscntrl(s[i])) {
s[i] = '.';
}