uniblock: only emit U+200E when necessary

This commit is contained in:
nick black 2020-08-16 02:38:53 -04:00
parent 8b072c0b5f
commit b63cad270f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -4,6 +4,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unictype.h>
#include "demo.h" #include "demo.h"
// show unicode blocks. a block is always a multiple of 16 codepoints. // 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){ if(wcwidth(w) < 2){
utf8arr[bwc++] = ' '; utf8arr[bwc++] = ' ';
} }
utf8arr[bwc++] = 0xe2; if(uc_bidi_category(w)){
utf8arr[bwc++] = 0x80; utf8arr[bwc++] = 0xe2;
utf8arr[bwc++] = 0x8e; utf8arr[bwc++] = 0x80;
utf8arr[bwc++] = 0x8e;
}
utf8arr[bwc++] = '\0'; utf8arr[bwc++] = '\0';
}else{ // don't dump non-printing codepoints }else{ // don't dump non-printing codepoints
strcpy(utf8arr, " "); strcpy(utf8arr, " ");