From 29f0b3c5e1184421ee7796ab2e1841733c45f403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 26 Dec 2022 18:00:28 +0100 Subject: [PATCH] Use Unicode replacement character MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In unicode mode replace non-printable characters with the Unciode replacement character U+FFFD ("�"). --- RichString.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RichString.c b/RichString.c index 3dac0832..daa0c91f 100644 --- a/RichString.c +++ b/RichString.c @@ -61,7 +61,7 @@ static inline int RichString_writeFromWide(RichString* this, int attrs, const ch int newLen = from + len; RichString_setLen(this, newLen); for (int i = from, j = 0; i < newLen; i++, j++) { - this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (iswprint(data[j]) ? data[j] : '?') } }; + this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (iswprint(data[j]) ? data[j] : L'\xFFFD') } }; } return len; @@ -79,7 +79,7 @@ int RichString_appendnWideColumns(RichString* this, int attrs, const char* data_ int columnsWritten = 0; int pos = from; for (int j = 0; j < len; j++) { - wchar_t c = iswprint(data[j]) ? data[j] : '?'; + wchar_t c = iswprint(data[j]) ? data[j] : L'\xFFFD'; int cwidth = wcwidth(c); if (cwidth > *columns) break; @@ -101,7 +101,7 @@ static inline int RichString_writeFromAscii(RichString* this, int attrs, const c int newLen = from + len; RichString_setLen(this, newLen); for (int i = from, j = 0; i < newLen; i++, j++) { - this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (isprint(data[j]) ? data[j] : '?') } }; + this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (isprint(data[j]) ? data[j] : L'\xFFFD') } }; } return len;