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: Tue, 20 Aug 2024 00:51:18 -0700 Message-ID: <87o75neio9.fsf@ushin.org> References: <87wmkbekjp.fsf@ushin.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="23366"; mail-complaints-to="usenet@ciao.gmane.io" To: Emacs Devel Mailing List Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 20 13:06:26 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 1sgMgz-0005vl-Gi for ged-emacs-devel@m.gmane-mx.org; Tue, 20 Aug 2024 13:06:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sgMgK-000658-Pi; Tue, 20 Aug 2024 07:05: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 1sgJeI-0007XA-Lc for emacs-devel@gnu.org; Tue, 20 Aug 2024 03:51:26 -0400 Original-Received: from out-185.mta0.migadu.com ([91.218.175.185]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sgJeG-0006qv-9k for emacs-devel@gnu.org; Tue, 20 Aug 2024 03:51:26 -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=1724140281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QZcMMWIHYudJ7WEOgqUT2BJYXO7yBtVSX6AqWNj5sjg=; b=uYW0XqaIYjWJJVbEddLIDrQ1YXBg/c7Vf4LWW6qA8C8VzrCwDo5XmAfBhCNEKo8se/za87 l1HOxDc4RsIdH54WgX71hv9/hjInhC7avd1Pc23MOgIz+lWLeXK3rHngC/4tMfZbKLeAZ1 PfE/xyFuI5AU9yRakDtOtiIy4rJY5CBG8WXjQ2s++8AMK3/oNF9fN7a9cZx7o231TIYfPO 2UN031GowM2NVNtadvwV9Kc0oHka38cBijmlRUHolU1KxnXirLNuQaBaZAPK9+kSZg+Dt9 88ibZAF+YY1Xsag0HRoIy3KjSNRP/uWyejK1ibOGkNL+N6Hg+gEIniqmBpplyw== In-Reply-To: <87wmkbekjp.fsf@ushin.org> (Joseph Turner's message of "Tue, 20 Aug 2024 00:10:50 -0700") X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.185; envelope-from=joseph@ushin.org; helo=out-185.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 20 Aug 2024 07:05:39 -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:322953 Archived-At: Joseph Turner writes: > How can I get a buffer's byte length without writing to a file? This seems to work: (with-temp-buffer (insert "=E4=BD=A0=E5=A5=BD") (set-buffer-multibyte nil) (buffer-size)) ;; 6 although, curiously, this does not: (with-temp-buffer (set-buffer-multibyte nil) (insert "=E4=BD=A0=E5=A5=BD") (buffer-size)) ;; 2 Is the `set-buffer-multibyte' approach the best solution? If I have a multibyte string and I want the byte length, do I need to insert it into a buffer and perform the same dance as above? Thank you! Joseph