From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: How to find the character breaking the file encoding? Date: Wed, 05 Feb 2020 03:42:29 +0100 Message-ID: <87lfphyctm.fsf@telefonica.net> References: <87a75yxc5q.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="8536"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.60 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:j07MXKL4DuKnSuiPbE1Dy7NhSjE= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 05 03:43:04 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1izAee-00025i-8q for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 05 Feb 2020 03:43:04 +0100 Original-Received: from localhost ([::1]:40686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izAed-0007UJ-B6 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 Feb 2020 21:43:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izAeJ-0007UC-W5 for help-gnu-emacs@gnu.org; Tue, 04 Feb 2020 21:42:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izAeG-0005Tj-2B for help-gnu-emacs@gnu.org; Tue, 04 Feb 2020 21:42:43 -0500 Original-Received: from ciao.gmane.io ([159.69.161.202]:57824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1izAeF-0005Nq-S2 for help-gnu-emacs@gnu.org; Tue, 04 Feb 2020 21:42:40 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1izAeE-0001YA-8V for help-gnu-emacs@gnu.org; Wed, 05 Feb 2020 03:42:38 +0100 X-Injected-Via-Gmane: http://gmane.org/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122351 Archived-At: Marcin Borkowski writes: > I have a large UTF-8 file (about 1.5MB) to which I add stuff regularly. > Recently, Emacs started saving it as a binary file. I suspect I somehow > inserted a non-UTF-8 sequence of bytes there. Is there any way Emacs > can help me finding it (other than me manually bisecting the file until > I find the offending place)? Try using M-x encode-coding-region ENTERT utf-8 ENTER With some luck this will mark the buffer as modified because it replaces unencodable content with blanks (IIRC). Then you can use M-x diff-buffer-with-file to see the line that contains the problematic sequence.