Subject: Re: bug#48324: 27.2; hexl-mode duplicates the UTF-8 BOM

From: Eli Zaretskii <[email-masked]>
Date: Mon, 10 May 2021 20:51:38 +0300

> Cc: [email-masked], [email-masked],
>  Andreas Schwab <[email-masked]>
> From: "R. Diez" <[email-masked]>
> Date: Mon, 10 May 2021 19:43:20 +0200
> 
> - I created an empty file with Caja (the MATE Desktop file manager) named Test7.txt . That empty file is 0 bytes long.
> - I then dragged the file to Emacs in order to open it.
> The default encoding is utf-8-unix (visible on Emacs' status line).
> - I pressed my keyboard shortcut for (eval-expression).
> - I changed the encoding by manually evaluating this expression:
> (set-buffer-file-coding-system 'utf-8-with-signature-dos)
> - I then typed in the buffer for Text7.txt the characters "123".
> - I saved the buffer with menu "File", option "Save".
> - I ran in the minibuffer command hexl-mode, which gives me the hex view for that file:
> ef bb bf 31 32 33 0d 0a
> - I moved the cursor with the arrow keys to the byte with value "31".
> - I ran in the minibuffer command hexl-insert-hex-char, in order to overwrite the 31 with a new value.
> - I typed in the minibuffer the hex value "00" (a binary null) and pressed enter.
> - In the hex view, the BOM is now duplicated.

Thanks, I see it now.

FTR, here's a shorter and easier recipe:

  emacs -Q
  C-x C-f foo.txt RET
  C-x RET f utf-8-with-signature-dos RET
  1 2 3
  C-x C-s
  M-x hexl-mode RET
  M-x hexl-insert-hex-char RET 00 RET