minibar: show Unicode codes when in a UTF-8 locale

The only exception is 0x00.  But that code should really not occur
in a normal text.  And if it does, it is fine that it stands out.
This commit is contained in:
Benno Schulenberg 2021-01-07 10:33:04 +01:00
parent 10b99d8ac0
commit 297633d086
1 changed files with 4 additions and 1 deletions

View File

@ -2138,10 +2138,13 @@ void minibar(void)
char *this_position = openfile->current->data + openfile->current_x;
if (*this_position == '\0')
sprintf(hexadecimal, openfile->current->next ? " 0x0A" : "------");
sprintf(hexadecimal, openfile->current->next ?
(using_utf8() ? "U+000A" : " 0x0A") : " ----");
else if (*this_position == '\n')
sprintf(hexadecimal, " 0x00");
#ifdef ENABLE_UTF8
else if ((unsigned char)*this_position < 0x80 && using_utf8())
sprintf(hexadecimal, "U+%04X", (unsigned char)*this_position);
else if ((unsigned char)*this_position > 0xC1 && using_utf8() &&
mbtowc(&widecode, this_position, MAXCHARLEN) >= 0)
sprintf(hexadecimal, "U+%04X", widecode);