From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Why does using aset sometimes output raw bytes? Date: Sun, 09 Dec 2018 17:20:13 +0200 Message-ID: <83y38y3exe.fsf@gnu.org> References: <87h8fmohmo.fsf@gmx.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1544368756 9465 195.159.176.226 (9 Dec 2018 15:19:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Dec 2018 15:19:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 09 16:19:12 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 1gW0rO-0002Hd-6L for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Dec 2018 16:19:10 +0100 Original-Received: from localhost ([::1]:55740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW0tU-00019c-Ox for geh-help-gnu-emacs@m.gmane.org; Sun, 09 Dec 2018 10:21:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW0sn-0000zR-Do for help-gnu-emacs@gnu.org; Sun, 09 Dec 2018 10:20:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW0se-0002h7-Dn for help-gnu-emacs@gnu.org; Sun, 09 Dec 2018 10:20:34 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW0se-0002gG-8G for help-gnu-emacs@gnu.org; Sun, 09 Dec 2018 10:20:28 -0500 Original-Received: from [176.228.60.248] (port=3119 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gW0sd-0002SQ-RP for help-gnu-emacs@gnu.org; Sun, 09 Dec 2018 10:20:28 -0500 In-reply-to: <87h8fmohmo.fsf@gmx.net> (message from Stephen Berman on Sun, 09 Dec 2018 16:16:15 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:118938 Archived-At: > From: Stephen Berman > Date: Sun, 09 Dec 2018 16:16:15 +0100 > > When I use aset to change characters in a string to certain non-ascii > characters and insert the result into a buffer, the non-ascii characters > are displayed as raw bytes. This only happens with certain non-ascii > characters, and also only if the string being altered is bound to a > variable and aset takes that variable as argument; if aset operates > directly on the string, those same non-ascii characters are inserted as > the expected characters. To reproduce, start emacs with -Q and evaluate > the following sexp: > > (let ((s0 "aous") > (s1 "äöüß") > (s2 "sdfg") > (s3 "ſðđŋ")) > (dolist (s `((,s0 . ,s1) (,s2 . ,s3))) > (dotimes (i 4) > (aset (car s) i (aref (cdr s) i)))) > (insert s0 s2 "\n") > (dotimes (i 4) > (insert (aset "aous" i (aref "äöüß" i)))) > (dotimes (i 4) > (insert (aset "sdfg" i (aref "ſðđŋ" i))))) > > Here's what gets inserted into the buffer (I've represented the raw > bytes by ascii strings to make sure they're readable here): > > \344\366\374\337ſðđŋ > äöüßſðđŋ > > Is this expected, and if so, what's the explanation, i.e., why does this > happen with some non-ascii characters (e.g. äöüß) but not with others > (e.g ſðđŋ) and why does it happen when aset gets passed a variable > for the string but not when it gets passed the string itself? s0 and s2 originally include only pure ASCII characters, so they are unibyte strings. Try making them multibyte before using aset.