mirror of git://git.sv.gnu.org/nano.git
minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN
An invalid UTF-8 starter byte should not be represented in the same way as a valid Unicode character. This fixes https://savannah.gnu.org/bugs/?59832. Bug existed since two weeks ago, since the mini-bar code was merged.
This commit is contained in:
parent
5129e718d7
commit
0693d6974a
10
src/winio.c
10
src/winio.c
|
@ -2138,14 +2138,16 @@ void minibar(void)
|
|||
char *this_position = openfile->current->data + openfile->current_x;
|
||||
|
||||
if (*this_position == '\0')
|
||||
sprintf(hexadecimal, openfile->current->next ? "U+000A" : "------");
|
||||
sprintf(hexadecimal, openfile->current->next ? " 0x0A" : "------");
|
||||
else if (*this_position == '\n')
|
||||
sprintf(hexadecimal, "U+0000");
|
||||
else if ((unsigned char)*this_position > 0xC1 &&
|
||||
sprintf(hexadecimal, " 0x00");
|
||||
#ifdef ENABLE_UTF8
|
||||
else if ((unsigned char)*this_position > 0xC1 && using_utf8() &&
|
||||
mbtowc(&widecode, this_position, MAXCHARLEN) >= 0)
|
||||
sprintf(hexadecimal, "U+%04X", widecode);
|
||||
#endif
|
||||
else
|
||||
sprintf(hexadecimal, "U+%04X", (unsigned char)*this_position);
|
||||
sprintf(hexadecimal, " 0x%02X", (unsigned char)*this_position);
|
||||
|
||||
mvwaddstr(bottomwin, 0, COLS - 23, hexadecimal);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue