nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 297633d086c0ac400081822b6fe55e30b1b2758f
parent 10b99d8ac0f85e23c88ddb860bb5c76682178713
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu,  7 Jan 2021 10:33:04 +0100

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.

Diffstat:
Msrc/winio.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/winio.c b/src/winio.c @@ -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);