From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How to get buffer byte length (not number of characters)? Date: Fri, 23 Aug 2024 10:02:24 +0300 Message-ID: <86frqvrabj.fsf@gnu.org> References: <87wmkbekjp.fsf@ushin.org> <86o75nwilg.fsf@gnu.org> <87bk1lhkvg.fsf@ushin.org> <86y14pu5rp.fsf@gnu.org> <871q2hfn7c.fsf@ushin.org> <86plq1td4n.fsf@gnu.org> <87ed6hdnpe.fsf@ushin.org> <865xrsu8c8.fsf@gnu.org> <87ttfcl8bn.fsf@ushin.org> <86zfp4qtxn.fsf@gnu.org> <878qwnj3j0.fsf@ushin.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11050"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net To: Joseph Turner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Aug 23 09:03:30 2024 Return-path: Envelope-to: ged-emacs-devel@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 1shOKY-0002hK-FO for ged-emacs-devel@m.gmane-mx.org; Fri, 23 Aug 2024 09:03:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shOJc-0005gY-8V; Fri, 23 Aug 2024 03:02:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shOJa-0005gJ-Hg for emacs-devel@gnu.org; Fri, 23 Aug 2024 03:02:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shOJZ-0002lc-5V; Fri, 23 Aug 2024 03:02:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=DEaSmh2CW0KSFk8cXchODujhS1mL0KC1hWHBljhIg6Y=; b=MgnsZQd4oWi9 syMBkRUJqFXQTKcAS7DEXu4/iqklSLhCOWdB8053e1XdF0O+CRwgGmltANUVrIttJ35I7qIKuCurP hb+mJWv9zFVxyG9pdygPHwFebciEEI1AfeKInCkoy7Xc9xELZcbr4QkS8VSyx5rh94u1vsFqHHZKe VfyP7vjFuVnDgWrqjxAsGYX7NuzJVLino5jcIAnrKJZHgN8GXxm5ddcJzOA2n8kyYfOGHbJqSDR86 kEXu/Hdn51o9IwMmky2AcXZSzJ3u8oCsiWyvp9xQIsZKZvLV09yho1wWysSwJmeW9KWADlyDRA89R PwJCNMecz6CX3VBhgVvbNw==; In-Reply-To: <878qwnj3j0.fsf@ushin.org> (message from Joseph Turner on Thu, 22 Aug 2024 20:56:19 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323072 Archived-At: > From: Joseph Turner > Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net > Date: Thu, 22 Aug 2024 20:56:19 -0700 > > Eli Zaretskii writes: > > >> For encoding text, should we encode with buffer-file-coding-system? > > > > If you are sure it will do, yes. But what if the buffer started as > > all-ASCII and then the user or some Lisp program added some non-ASCII > > characters before saving? Then buffer-file-coding-system is no longer > > pertinent. > > I understand. Thank you! > > How do we encode if find-coding-systems-region returns '(undecided)? Use buffer-file-coding-system. If this is an interactive command, you could also use select-safe-coding-system, which calls find-coding-systems-region internally, and also has complex logic for finding suitable callbacks and asking the user to select an encoding if it fails to find something suitable. But this is not appropriate in non-interactive code.