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 20:35:41 +0300 Message-ID: <86h6bbp2fm.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> <86frqvrabj.fsf@gnu.org> <87le0nfzuv.fsf@ushin.org> <865xrrquru.fsf@gnu.org> <87o75j5g5x.fsf@ushin.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39734"; 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 19:36: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 1shYD8-000A9c-8A for ged-emacs-devel@m.gmane-mx.org; Fri, 23 Aug 2024 19:36:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shYCS-0003aw-Ix; Fri, 23 Aug 2024 13:35:48 -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 1shYCO-0003L3-Bq for emacs-devel@gnu.org; Fri, 23 Aug 2024 13:35:44 -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 1shYCN-0007yS-L8; Fri, 23 Aug 2024 13:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=IdeSunghdIyoaOyEpaCuLmSCwRe7SBaos/EdgOyKT0M=; b=Kz1tw9aiOx5Dx0rHDFN9 llOpRx9tuLiK7nUrU1zpxDLiNl1swAgShvXxK9klMnMVHv5MxoAt84WgZHCn0nS74OJx3R1zKDFTA 3nVYSz+G2WMzPqX+95LY99bPEUI5mVeugpGuTu14zLnYfQiYTma8QG4UKsw5DUjShhNnFjDmIRTVW F+O7OmbbCVxvKkQNzSRaiC9ZrwKpx5Z6rOMDQ2nVbXDlnpLOmGSbB+U0qOWmzWiDHDRJ9wrEEvfUT 8IFi9O/1sqJ6B8QcvuTN6yHHeXpmumVuEW0g7ps6xVptG0NYK3VZiTYQhGnW89Ytf27ozgs6+taM4 FEhAu2CQesdxYw==; In-Reply-To: <87o75j5g5x.fsf@ushin.org> (message from Joseph Turner on Fri, 23 Aug 2024 09:59:22 -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:323096 Archived-At: > From: Joseph Turner > Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net > Date: Fri, 23 Aug 2024 09:59:22 -0700 > > Eli Zaretskii writes: > > >> From: Joseph Turner > >> Cc: emacs-devel@gnu.org, schwab@suse.de, adam@alphapapa.net > >> Date: Fri, 23 Aug 2024 00:43:52 -0700 > >> > >> I'm surprised that > >> > >> (with-temp-buffer > >> (insert "你好") > >> (set-buffer-file-coding-system 'chinese-big5) > >> (car (find-coding-systems-region (point-min) (point-max)))) > >> > >> returns 'utf-8 and not 'chinese-big5. > > > > What does coding-system-priority-list returns in your case? > > '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. > > 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.