From 6411b628a44915540fbe19271e1e7a0945113844 Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 20 Oct 2021 03:20:55 -0500 Subject: [PATCH] [utf8_egc_len] don't disqualify output based off wcwidth() #2285 --- src/lib/egcpool.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/egcpool.h b/src/lib/egcpool.h index f298d11b2..9cee4e6f3 100644 --- a/src/lib/egcpool.h +++ b/src/lib/egcpool.h @@ -103,7 +103,7 @@ utf8_egc_len(const char* gcluster, int* colcount){ r = mbrtowc(&wc, gcluster, MB_CUR_MAX, &mbt); if(r < 0){ // FIXME probably ought escape this somehow - logerror("Invalid UTF8: %s\n", gcluster); + logerror("invalid UTF8: %s\n", gcluster); return -1; } if(prevw && !injoin && uc_is_grapheme_break(prevw, wc)){ @@ -114,8 +114,11 @@ utf8_egc_len(const char* gcluster, int* colcount){ if(iswspace(wc)){ // newline or tab return ret + 1; } - logerror("Prohibited or invalid Unicode: 0x%x\n", wc); - return -1; + if(iswcntrl(wc)){ + logerror("prohibited or invalid Unicode: 0x%x\n", wc); + return -1; + } + cols = 1; } injoin = (wc == L'\u200d'); *colcount += cols;