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 19:13:36 +0200 Message-ID: <83bm74epfj.fsf@gnu.org> References: <16B3CA28-C893-4854-AD64-1C224C1EDDB2@outlook.com> <83efc0ew3f.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1541351551 29581 195.159.176.226 (4 Nov 2018 17:12:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Nov 2018 17:12:31 +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 18:12:26 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 1gJLwm-0007Z7-Dt for ged-emacs-devel@m.gmane.org; Sun, 04 Nov 2018 18:12:24 +0100 Original-Received: from localhost ([::1]:59663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJLys-0006SR-Mh for ged-emacs-devel@m.gmane.org; Sun, 04 Nov 2018 12:14:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJLy7-0006SA-RN for emacs-devel@gnu.org; Sun, 04 Nov 2018 12:13:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJLy4-0000UH-OO for emacs-devel@gnu.org; Sun, 04 Nov 2018 12:13:47 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJLy4-0000Tb-CK; Sun, 04 Nov 2018 12:13:44 -0500 Original-Received: from [176.228.60.248] (port=3901 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gJLy3-0003OE-TT; Sun, 04 Nov 2018 12:13:44 -0500 In-reply-to: (message from Zhang Haijun on Sun, 4 Nov 2018 15:14:07 +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:231009 Archived-At: > From: Zhang Haijun > CC: "emacs-devel@gnu.org" > Date: Sun, 4 Nov 2018 15:14:07 +0000 > > > 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. > > OK. Thanks for your explanation. I like the behavior of revert-buffer. > It may be useful to print some warning message when there are invalid bytes. > How to search invalid bytes in buffer? They are not invalid bytes, they are zero bytes. You can search for them like this: C-s C-q C-SPC