From 0167f78dcae4e53f12d27ff1d1c0c3f41af85c20 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 20 Nov 2022 11:25:45 +0100 Subject: [PATCH] feedback: warn when the cursor sits on a Byte Order Mark (BOM) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ceck is only done at the start of a line, because in other places the BOM will be glued to the preceding character. This partially addresses https://bugs.debian.org/964901. Reported-by: Nils König --- src/nano.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nano.c b/src/nano.c index 7bd06326..39b93523 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2683,6 +2683,16 @@ int main(int argc, char **argv) as_an_at = TRUE; +#if defined(ENABLE_UTF8) && !defined(NANO_TINY) +#define byte(n) (unsigned char)openfile->current->data[n] + /* Tell the user when the cursor sits on a BOM. */ + if (openfile->current_x == 0 && byte(0) == 0xEF && byte(1) == 0xBB && + byte(2) == 0xBF && using_utf8()) { + statusline(NOTICE, _("Byte Order Mark")); + set_blankdelay_to_one(); + } +#endif + if ((refresh_needed && LINES > 1) || (LINES == 1 && lastmessage <= HUSH)) edit_refresh(); else