diff --git a/src/chars.c b/src/chars.c index 134bad3c..de28d420 100644 --- a/src/chars.c +++ b/src/chars.c @@ -150,7 +150,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len) if (c_mb_len <= 0) { mbtowc(NULL, NULL, 0); - wc = *c; + wc = (unsigned char)*c; } wcrep = control_wrep(wc); @@ -237,14 +237,13 @@ char *make_mbchar(unsigned int chr, char *chr_mb, int *chr_mb_len) *chr_mb_len = wctomb(chr_mb, chr); if (*chr_mb_len <= 0) { - mbtowc(NULL, NULL, 0); - *chr_mb_len = 1; - chr_mb[0] = (unsigned char)chr; + wctomb(NULL, 0); + *chr_mb_len = 0; } } else { #endif *chr_mb_len = 1; - chr_mb[0] = (unsigned char)chr; + chr_mb[0] = (char)chr; #ifdef NANO_WIDE } #endif diff --git a/src/winio.c b/src/winio.c index 3a99ea7d..328fafc3 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2190,7 +2190,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool char *bad_buf_mb = charalloc(mb_cur_max()); int bad_buf_mb_len; - bad_buf_mb = make_mbchar((unsigned int)*buf_mb, + bad_buf_mb = make_mbchar((unsigned char)*buf_mb, bad_buf_mb, &bad_buf_mb_len); for (i = 0; i < bad_buf_mb_len; i++)