From b63cad270f8bc0c9e88515d6a630ad58a93641b5 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 16 Aug 2020 02:38:53 -0400 Subject: [PATCH] uniblock: only emit U+200E when necessary --- src/demo/unicodeblocks.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/demo/unicodeblocks.c b/src/demo/unicodeblocks.c index 7779a14d9..29436b39e 100644 --- a/src/demo/unicodeblocks.c +++ b/src/demo/unicodeblocks.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "demo.h" // show unicode blocks. a block is always a multiple of 16 codepoints. @@ -74,9 +75,11 @@ draw_block(struct ncplane* nn, uint32_t blockstart){ if(wcwidth(w) < 2){ utf8arr[bwc++] = ' '; } - utf8arr[bwc++] = 0xe2; - utf8arr[bwc++] = 0x80; - utf8arr[bwc++] = 0x8e; + if(uc_bidi_category(w)){ + utf8arr[bwc++] = 0xe2; + utf8arr[bwc++] = 0x80; + utf8arr[bwc++] = 0x8e; + } utf8arr[bwc++] = '\0'; }else{ // don't dump non-printing codepoints strcpy(utf8arr, " ");