From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Why does using aset sometimes output raw bytes? Date: Sun, 09 Dec 2018 18:32:26 +0100 Message-ID: <87wooimwr9.fsf@gmx.net> References: <87h8fmohmo.fsf@gmx.net> <83y38y3exe.fsf@gnu.org> <87d0qaog92.fsf@gmx.net> <83r2eq39q7.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1544376659 26456 195.159.176.226 (9 Dec 2018 17:30:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Dec 2018 17:30:59 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 09 18:30:55 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gW2us-0006nC-Sy for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Dec 2018 18:30:55 +0100 Original-Received: from localhost ([::1]:56121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW2wz-0003QH-BO for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Dec 2018 12:33:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW2wV-0003Q9-3b for help-gnu-emacs@gnu.org; Sun, 09 Dec 2018 12:32:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW2wQ-0006Wf-56 for help-gnu-emacs@gnu.org; Sun, 09 Dec 2018 12:32:35 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:54711) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gW2wP-0006Rp-Px; Sun, 09 Dec 2018 12:32:30 -0500 Original-Received: from rosalinde ([88.74.23.82]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LnxQO-1h7ZYK0GYS-00fyQy; Sun, 09 Dec 2018 18:32:28 +0100 In-Reply-To: <83r2eq39q7.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 09 Dec 2018 19:12:32 +0200") X-Provags-ID: V03:K1:Vx1HH/QQN35KOE4RBwG5gVALWbLRuG0NNpjLZajyxyRFzy6PPlB MculEBXa99yhcfkutsB2gId3NVZcb0ln4IIyZhquFCuKUWVLbgIiusuQGQ0eYB2vkLtixMy mlrs5jdx/YOIBHYik0q9Fq8wFG9BgY66zFRE4dLXM4MH4y2eGFu5ED/Oyl5ycVZtPEaYfcJ Pt8L2X60A1zbZrCgapHpQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:xdcT+/MUI0I=:rgD2sgwsglNFJCGDkqQWHR rSL+qG8z8vlJpv1BPAc9joYKHSCQaHWFw637r23eBRpZB4+WSgQ5i94+kFqWrqCv4GeMkYBHz N8fxl2km8lh7/l3nGGSbkB1H4s0UTPwFH7g1MBkDzFSsUK0XKFvhFDo8gcLl1puWHj/EgdBd0 qDffCny3XR8dk5SlqhIpb18bOJEwGgWq364z2zl22KnJ5XEeCMHVXG/X/BQ+rdTSR0jVx+yo1 7d2gaYDsQ9MSZ1B+Jiyx+PSBDsISulzJmxhhQ3Ihk8bvtr6WoBYvZuCUzaqemfmYNs5EqAs0A UM9i+Iq0JrnuVctWQHkGOSVm+lvHi85hEAmP75v2+DaVu9cYUw0S4WjmyB1GwmrjzupwBdUmO co2JKU/TKt3wEFh3oqpWv9ktbvlz/FnsM7YLiw2SAJ57KI8DX0hgdKOnlpb78bmkxtSAeb6bh ZPS5oCkU1C0WNVSmAS7R9Ofaan/FA3rXNcPWOf2p/XOKyfAYKZfTh7mvoteSJlarz7TNsPEp3 PWoocez+yEdX7CXFq4m0EKtf/sdvcWasCk1nAhkRfJ6yvoLZ8uW63aUixXtS11+dgq4FSQqXQ CYn6p2jTpAnkHEu1nqa3QQ9uIWdVY8qqGUGFAK/V1lHbj7yN8PILkHwlsANdr/xQpzJBUjgpd AZrg1Y/+QUUv4XwwB24sy1deYE1y7448DQJVSRdVnByAA6x96prc5JU6n4idSMFBocrSgOyal bYuMMj2FIM22su5OJkHSwgD/7/TncdmuUnlIeFB6ObIehcz8N8NcY+X5Nks7Atax2o7HcFsX X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118945 Archived-At: On Sun, 09 Dec 2018 19:12:32 +0200 Eli Zaretskii wrote: >> From: Stephen Berman >> Cc: help-gnu-emacs@gnu.org >> Date: Sun, 09 Dec 2018 16:46:01 +0100 >>=20 >> > s0 and s2 originally include only pure ASCII characters, so they are >> > unibyte strings. Try making them multibyte before using aset. >>=20 >> Thanks, that works. But why are raw bytes inserted only with some >> multibyte strings (e.g. with "=C3=A4=C3=B6=C3=BC=C3=9F" but not with "= =C5=BF=C3=B0=C4=91=C5=8B")? > > Because =C5=BF doesn't fit in a single byte, so when you insert it, the > entire string is made multibyte, and then the other characters are > inserted into a multibyte string. This seems to imply that =C3=A4, =C3=B6, =C3=BC and =C3=9F do fit in a sing= le byte? Yet (multibyte-string-p "=C3=A4=C3=B6=C3=BC=C3=9F") returns t. So I still don'= t understand. >> Also, is there some way to ensure a string is handled as multibyte >> if it's not known what characters it contains? E.g., s0 in my >> example sexp could be bound to some string by a function call and >> before applying the function it is not known if the string is >> multibyte; > > You should generally keep away of such situations, but you don't tell > enough about what you are trying to accomplish to give more practical > advice. Nothing serious, just some experimenting. > To answer your question: you can test whether a string is multibyte > with multibyte-string-p, and you can make it multibyte if not. The > only problematic situation is when a unibyte string includes non-ASCII > bytes; what is TRT in that situation depends on the situation. > >> is there some way in Lisp to say "treat the value of s0 as multibyte >> (regardless of what characters it contains)"? > > Not that I know of, no. And I don't really understand how could such > a thing exist: how do you "treat as multibyte" an arbitrary byte that > is beyond 127 decimal? Actually, for the code I was experimenting with, it seems to suffice to use (make-string len 128) as the input to aset (before, I had used (make-string len 32), which led to raw bytes being displayed). > >> Also "aous" is also pure ASCII, so why don't raw bytes get inserted with >> (insert (aset "aous" i (aref "=C3=A4=C3=B6=C3=BC=C3=9F" i)))? > > This inserts characters one by one into the current buffer, and the > buffer is multibyte, so Emacs does the conversion. IOW, you don't > insert the string, you insert individual characters which aset > returns. Ah, this makes sense. Thanks. Steve Berman