From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner Newsgroups: gmane.emacs.devel Subject: Re: How to get buffer byte length (not number of characters)? Date: Fri, 23 Aug 2024 13:37:33 -0700 Message-ID: <87cylz3rhu.fsf@ushin.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> <86frqvrabj.fsf@gnu.org> <87le0nfzuv.fsf@ushin.org> <865xrrquru.fsf@gnu.org> <87o75j5g5x.fsf@ushin.org> <86h6bbp2fm.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20590"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 24 07:12:34 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 1shj4j-0005Ck-Bf for ged-emacs-devel@m.gmane-mx.org; Sat, 24 Aug 2024 07:12:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shj3w-0004fx-Ky; Sat, 24 Aug 2024 01:11:44 -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 1shb2e-0003fq-18 for emacs-devel@gnu.org; Fri, 23 Aug 2024 16:37:52 -0400 Original-Received: from out-186.mta1.migadu.com ([95.215.58.186]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shb2c-0003mm-8i for emacs-devel@gnu.org; Fri, 23 Aug 2024 16:37:51 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1724445458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YNk1aEvGzepWlcNglE2R/AwtoeP0kCMlKM3NYD4VzMI=; b=OXPsXjWDc+Y/Hd4U8B2EiO8k//XdkN0oGPdgAvN7jj4Vh7tZab69F1gOzbTM5cmO4nNYyi SI74Cg7GIu4o8tRnuH7AAmXnKXVrUdUDfpkjoIha4vH/Zl+mmJq2a3OPEFVRibjYUXp1Fk F4kg79OaehFeYRxiVZhn9k2SETtw+6m4xmID+YNdEBBcpRXkp6siN34dGPg631Z1qf2Ha4 okk1Yyl+g7QzWkUUvnGm2oWyOr1PB9VbXqjDsjSqeEIAcWpeMGVmmYeYyPLQSsnSUmO+gR qzrji5llyMvQTIhvIgCbGqnjmdRcYP5kadc2zesb/IYeVoIMrGwY2IU9OWxWBQ== In-Reply-To: <86h6bbp2fm.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 23 Aug 2024 20:35:41 +0300") X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.186; envelope-from=joseph@ushin.org; helo=out-186.mta1.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 24 Aug 2024 01:11:42 -0400 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:323104 Archived-At: Eli Zaretskii writes: >> From: Joseph Turner >> Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net >> Date: Fri, 23 Aug 2024 09:59:22 -0700 >>=20 >> Eli Zaretskii writes: >>=20 >> >> From: Joseph Turner >> >> Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net >> >> Date: Fri, 23 Aug 2024 00:43:52 -0700 >> >>=20 >> >> I'm surprised that >> >>=20 >> >> (with-temp-buffer >> >> (insert "=E4=BD=A0=E5=A5=BD") >> >> (set-buffer-file-coding-system 'chinese-big5) >> >> (car (find-coding-systems-region (point-min) (point-max)))) >> >>=20 >> >> returns 'utf-8 and not 'chinese-big5. >> > >> > What does coding-system-priority-list returns in your case? >>=20 >> 'utf-8 > > That explains what you see, then. > >> >> Are the codings intended to be >> >> ordered by priority? >> > >> > Yes. >> > >> >> If so, should buffer-file-coding-system be at the front of the list >> >> if it's safe? >> > >> > How do you know it's safe? >> > >> > If your application needs to prefer buffer-file-coding-system, then >> > you should see if buffer-file-coding-system is a member of the list >> > returned by find-coding-systems-region, and if so, use that. >>=20 >> I'd have thought that most applications would want to prefer >> buffer-file-coding-system if it's a member of the list returned by >> find-coding-systems-region, but perhaps not. > > Most applications use select-safe-coding-system, which AFAIR already > does all that. Fantastic! Yes, it appears that select-safe-coding-system does account for buffer-file-coding-system. So, hyperdrive.el can just encode with (select-safe-coding-system (point-min) (point-max) nil nil FILENAME) Simple. Thank you!! Joseph