[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 19:47:03 +0200

> From: Stephen Berman <>
> Cc:
> Date: Sun, 09 Dec 2018 18:32:26 +0100
> >> why are raw bytes inserted only with some
> >> multibyte strings (e.g. with "äöüß" but not with "ſðđŋ")?
> >
> > Because ſ 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 ä, ö, ü and ß do fit in a single byte?  Yet
> (multibyte-string-p "äöüß") returns t.  So I still don't understand.

Look at the codepoints: the above are all less than FF hex, so they
can fit in a single byte.  By contrast, ſ is 17F hex, more than a
single byte can hold.  So inserting ſ into a unibyte string _must_
first make that string multibyte, whereas inserting ä etc. can leave
it unibyte.

Why (multibyte-string-p "äöüß") returns t is an unrelated issue: it
has to do with how the Lisp reader reads the string.  The result is a
multibyte string, where ä is represented by its UTF-8 sequence and not
by its single-byte codepoint E4 hex.  If you want a unibyte string
with these bytes, use (multibyte-string-p "\344\366\374\337") instead.

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

Not sure I understand what you mean by "suffice".  Feel free to ask
questions if there are some left.

reply via email to

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