From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Fwd: Re: Inadequate documentation of silly characters on screen. Date: Wed, 18 Nov 2009 20:27:24 -0500 Message-ID: References: <20091118191258.GA2676@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1258594569 10190 80.91.229.12 (19 Nov 2009 01:36:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Nov 2009 01:36:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 19 02:36:02 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NAvwI-0000zE-0A for ged-emacs-devel@m.gmane.org; Thu, 19 Nov 2009 02:36:02 +0100 Original-Received: from localhost ([127.0.0.1]:40198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAvwH-0002g8-Dn for ged-emacs-devel@m.gmane.org; Wed, 18 Nov 2009 20:36:01 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAvo3-0004Li-Qx for emacs-devel@gnu.org; Wed, 18 Nov 2009 20:27:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAvnz-0004IR-5c for emacs-devel@gnu.org; Wed, 18 Nov 2009 20:27:31 -0500 Original-Received: from [199.232.76.173] (port=47336 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAvny-0004IE-Oi for emacs-devel@gnu.org; Wed, 18 Nov 2009 20:27:26 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:20341 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NAvny-0002Gw-CN for emacs-devel@gnu.org; Wed, 18 Nov 2009 20:27:26 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAPAtBEvO+IIa/2dsb2JhbACBTdcUhDsEgwyGSw X-IronPort-AV: E=Sophos;i="4.44,768,1249272000"; d="scan'208";a="49633593" Original-Received: from 206-248-130-26.dsl.teksavvy.com (HELO pastel.home) ([206.248.130.26]) by ironport2-out.pppoe.ca with ESMTP; 18 Nov 2009 20:27:24 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id B87D98774; Wed, 18 Nov 2009 20:27:24 -0500 (EST) In-Reply-To: <20091118191258.GA2676@muc.de> (Alan Mackenzie's message of "Wed, 18 Nov 2009 19:12:58 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117227 Archived-At: > This is the message I meant to CC: to emacs-devel. It looks serious. The integer 241 is used to represent the char ?=F1, 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 ?=F1) 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 ?=F1 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