From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel 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 Message-ID: <83efc0ew3f.fsf@gnu.org> References: <16B3CA28-C893-4854-AD64-1C224C1EDDB2@outlook.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1541342877 31117 195.159.176.226 (4 Nov 2018 14:47:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Nov 2018 14:47:57 +0000 (UTC) Cc: emacs-devel@gnu.org To: Zhang Haijun Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 04 15:47:52 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJJgu-0007zn-Cn for ged-emacs-devel@m.gmane.org; Sun, 04 Nov 2018 15:47:52 +0100 Original-Received: from localhost ([::1]:59239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJJj0-0002XE-Et for ged-emacs-devel@m.gmane.org; Sun, 04 Nov 2018 09:50:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJJiq-0002Ww-Rl for emacs-devel@gnu.org; Sun, 04 Nov 2018 09:49:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJJin-00021A-Mr for emacs-devel@gnu.org; Sun, 04 Nov 2018 09:49:52 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJJil-0001yY-KX; Sun, 04 Nov 2018 09:49:48 -0500 Original-Received: from [176.228.60.248] (port=2818 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gJJik-0005aO-Ld; Sun, 04 Nov 2018 09:49:47 -0500 In-reply-to: <16B3CA28-C893-4854-AD64-1C224C1EDDB2@outlook.com> (message from Zhang Haijun on Sun, 4 Nov 2018 12:28:52 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231007 Archived-At: > From: Zhang Haijun > CC: "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.