emacs-devel
[Top][All Lists]
Advanced

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

Re: Fwd: Re: Inadequate documentation of silly characters on screen.


From: Stefan Monnier
Subject: Re: Fwd: Re: Inadequate documentation of silly characters on screen.
Date: Wed, 18 Nov 2009 20:27:24 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> This is the message I meant to CC: to emacs-devel.  It looks serious.

The integer 241 is used to represent the char ?ñ, but it's also used for
many other things, one of them being to represent the byte 241 (tho such
a byte can also be represented as the integer 4194289).

Now strings come in two flavors: multibyte (i.e. sequences of chars) and
unibyte (i.e. sequences of bytes).  So when you do:

   M-: (setq nl "\n")
   M-: (aset nl 0 ?ñ)
   M-: (insert nl)

The `aset' part may do two different things depending on whether `nl' is
unibyte or multibyte: it will either insert the char ?ñ or the byte 241.
In the above code the "\n" is taken as a unibyte string, tho I'm not
sure why we made this arbitrary choice.
If you give us more context (i.e. more of the real code where the
problem show up), maybe we can tell you how to avoid it.  Usually,
I recommend to stay away from `aset' on strings for various reasons, and
it seems that it also helps avoid those tricky issues (tho it
doesn't protect you from them completely).


        Stefan




reply via email to

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