unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: rdiezmail-emacs@yahoo.de, larsi@gnus.org, 48324@debbugs.gnu.org
Subject: bug#48324: 27.2; hexl-mode duplicates the UTF-8 BOM
Date: Tue, 11 May 2021 15:04:05 +0300	[thread overview]
Message-ID: <83cztx5vey.fsf@gnu.org> (raw)
In-Reply-To: <87bl9i4g7m.fsf@igel.home> (message from Andreas Schwab on Mon, 10 May 2021 20:05:33 +0200)

> From: Andreas Schwab <schwab@linux-m68k.org>
> Cc: "R. Diez" <rdiezmail-emacs@yahoo.de>,  larsi@gnus.org,
>   48324@debbugs.gnu.org
> Date: Mon, 10 May 2021 20:05:33 +0200
> 
> On Mai 10 2021, Eli Zaretskii wrote:
> 
> > 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
> 
> I guess the gist is that hexl-mode not only needs to account for the EOL
> type, but also for the signature when computing original-point.

Actually, it turned out that wasn't the main problem.  (It was still a
problem, but the same problem happened in a buffer produced by
hexl-find-file.)  The main problems were that (a) hexl.el handled null
bytes as characters that need to be encoded before inserting them (as
if they were non-ASCII characters), and (b) its handling of non-ASCII
characters when the encoding of the original file used a BOM was
incorrect (because encode-coding-char didn't remove the BOM from the
encoded byte sequence).  By contrast, hexl-find-file visits the file
literally, so its encoding of a null byte was trivially correct.

This should be now fixed on the master branch.

The capability of inserting multibyte characters via Hexl is somewhat
problematic, so I made a point of describing the issues in the
relevant doc strings (because the problems are intrinsic and IMO hard
or impossible to solve in general).





  reply	other threads:[~2021-05-11 12:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0ed1c9c7-26c1-b801-1910-6d5bb50dec3d.ref@yahoo.de>
2021-05-09 19:14 ` bug#48321: 27.2; Text copied from *grep* buffer has NUL (0x00) characters R. Diez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-09 21:38   ` bug#48324: 27.2; hexl-mode duplicates the UTF-8 BOM R. Diez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-10 14:17     ` Eli Zaretskii
     [not found]       ` <e250f934-6f7b-bec3-9df4-d2b242599a45@yahoo.de>
2021-05-10 16:13         ` Eli Zaretskii
2021-05-10 16:28           ` Lars Ingebrigtsen
2021-05-10 16:50             ` Andreas Schwab
2021-05-10 17:16               ` Eli Zaretskii
2021-05-10 17:43                 ` R. Diez via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-10 17:51                   ` Eli Zaretskii
2021-05-10 18:05                     ` Andreas Schwab
2021-05-11 12:04                       ` Eli Zaretskii [this message]
2021-05-11 20:37                         ` Glenn Morris
2021-05-12 13:50                           ` Eli Zaretskii
2022-07-02 16:14                             ` Lars Ingebrigtsen
2022-07-02 16:37                               ` Eli Zaretskii
2022-07-03 11:08                                 ` Lars Ingebrigtsen
2022-07-03 12:07                                   ` Lars Ingebrigtsen
2022-07-03 13:00                                     ` Eli Zaretskii
2022-07-03 13:26                                       ` Eli Zaretskii
2022-07-03 13:48                                         ` Andreas Schwab
2022-07-03 13:51                                           ` Eli Zaretskii
2022-07-04 10:34                                         ` Lars Ingebrigtsen
2022-07-04 11:31                                           ` Eli Zaretskii
2022-07-05 11:08                                             ` Lars Ingebrigtsen
2022-07-03 13:28                                       ` Lars Ingebrigtsen
2021-05-10 17:06             ` Eli Zaretskii
2021-05-11 12:53   ` bug#48321: 27.2; Text copied from *grep* buffer has NUL (0x00) characters Lars Ingebrigtsen
2022-07-02 15:59     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83cztx5vey.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=48324@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=rdiezmail-emacs@yahoo.de \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).