all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Zhang Haijun <ccsmile2008@outlook.com>
Cc: emacs-devel@gnu.org
Subject: Re: 26.1.50; Emacs can't decode the text file on opening the file, but	can decode it on revert-buffer
Date: Sun, 04 Nov 2018 16:49:40 +0200	[thread overview]
Message-ID: <83efc0ew3f.fsf@gnu.org> (raw)
In-Reply-To: <16B3CA28-C893-4854-AD64-1C224C1EDDB2@outlook.com> (message from Zhang Haijun on Sun, 4 Nov 2018 12:28:52 +0000)

> From: Zhang Haijun <ccsmile2008@outlook.com>
> CC: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Sun, 4 Nov 2018 12:28:52 +0000
> 
> > This file includes null bytes, which by default cause Emacs to disable all decoding, because such files are deemed to be binary files.
> > If you don't like this, set inhibit-null-byte-detection to a non-nil value.
> > 
> > This is not a bug, but the intended behavior.
> 
> Then why the encoding of the buffer changed after revert-buffer?

It's a subtle bug: revert-buffer reads and decodes the file in small
chunks, so by the time it gets to the furst null byte, it already
decided that the encoding is UTF-8.  By contrast, find-file decodes
the entire file at once, so it sees the null bytes when it detects the
encoding.

We had this behavior since Emacs 23.1; Emacs 22 doesn't change the
encoding when this buffer is reverted.



  parent reply	other threads:[~2018-11-04 14:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-04  8:44 26.1.50; Emacs can't decode the text file on opening the file, but can decode it on revert-buffer Zhang Haijun
2018-11-04  9:18 ` Eli Zaretskii
     [not found]   ` <16B3CA28-C893-4854-AD64-1C224C1EDDB2@outlook.com>
2018-11-04 14:49     ` Eli Zaretskii [this message]
     [not found]       ` <B213388B-58E6-4F5B-8CE8-79AC5AD3062B@outlook.com>
2018-11-04 17:13         ` Eli Zaretskii
2018-11-05  8:59           ` Zhang Haijun
2018-11-05  9:00           ` Zhang Haijun
2018-11-05  9:00           ` Zhang Haijun
2018-11-05  9:39             ` Phil Sainty
2018-11-05 10:10               ` Stephen Berman
2018-11-05 14:08               ` Zhang Haijun
2018-11-05 15:02                 ` Stephen Berman
2018-11-05 16:00                 ` Eli Zaretskii
2018-11-06  1:39                   ` Zhang Haijun
2018-11-06  3:31                     ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=83efc0ew3f.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=ccsmile2008@outlook.com \
    --cc=emacs-devel@gnu.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.