[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does using aset sometimes output raw bytes?

From: Eli Zaretskii
Subject: Re: Why does using aset sometimes output raw bytes?
Date: Sun, 09 Dec 2018 17:20:13 +0200

> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]