From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: More confusion about multibyte vs unibyte strings Date: Thu, 05 May 2022 22:23:36 +0300 Message-ID: <83tua3237r.fsf@gnu.org> References: <874k23or0c.fsf@ericabrahamsen.net> <83zgjv288x.fsf@gnu.org> <87v8ujn7ja.fsf@ericabrahamsen.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22281"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 05 22:18:37 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nmhvp-0005UD-8z for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 05 May 2022 22:18:37 +0200 Original-Received: from localhost ([::1]:47616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmhvo-0006l2-Bw for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 05 May 2022 16:18:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmh4q-0002P3-05 for help-gnu-emacs@gnu.org; Thu, 05 May 2022 15:23:53 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmh4p-0002CD-6y for help-gnu-emacs@gnu.org; Thu, 05 May 2022 15:23:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0o3vwgqiTn7v8IwWrQn/HjoJenfQKVSyInNFMbSh0Io=; b=JzUQtH3k41O1 lZ0DCXOnKFFTZ8erLmMuZkTGTGTowCPIxqcpWxw0306R++tGbo5AOWQdRQL5D9i7R8EBBo5+4cQmV febEQV6N2EP+p5LiBU8fiRhkoaRo0IUzPo9M4udBfbQ6iopR1dXbnEdgBLOjCWyfY+o09OBeaS/yJ NDcwZG7hc5PgiRbKiU8DfM6F5KKYMxraXOpCxyMNWfRtHQGOUcxoikSxrBEFp46L72SBD9ZJNqY42 22qwtuQ6Pm+xBde0aryMci7rPxVQHcP22YATr7ux/8tKdiud+zsFV18S5OMZE59xSV7iOY29fkD+W /FoTx/LAaOAZ6sZ6U9d40Q==; Original-Received: from [87.69.77.57] (port=2999 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmh4o-0003sG-M2 for help-gnu-emacs@gnu.org; Thu, 05 May 2022 15:23:50 -0400 In-Reply-To: <87v8ujn7ja.fsf@ericabrahamsen.net> (message from Eric Abrahamsen on Thu, 05 May 2022 11:44:41 -0700) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137155 Archived-At: > From: Eric Abrahamsen > Date: Thu, 05 May 2022 11:44:41 -0700 > > > Why does it "mess things up", and what exactly is the nature of the > > mess-up? A pure-ASCII string can be either unibyte or multibyte, and > > that shouldn't change a thing. > > If the string is not ASCII, we need to encode it before sending to the > server, and tell the server what encoding we used. Microsoft Exchange > servers can't handle any encoding other than ascii. What do you mean by "ascii encoding" in this context? When you say that Microsoft Exchange can't handle any encoding other than ascii, does it mean it cannot handle _any_ non-ASCII addressee names? That'd be hard to believe, because such addressee names are nowadays in wide use. So I guess you mean something else, but what? > So if our code thinks a string isn't ascii, it sends the encoding > message to the IMAP server, and Exchange blows up. Encoding ascii yields a string that is identical to the original (IIUC what you mean by "encoding"), so I don't follow you here. > If the string is ascii, we don't try to encode it, and everything's > fine. So I need to know whether the string is actually ascii or not. You can do that using the regexp class [:ascii:], I guess. > I can solve this some other way, like > (equal (length str) (string-bytes str)) That should return non-nil for unibyte string that includes bytes above 127 as well, no? > but I'm just trying to figure out why this doesn't behave the way I > expect it to. I'd thought that `multibyte-string-p' essentially > performed the above length test. No, it doesn't. A pure ASCII string can be made multibyte without changing its payload, and Emacs usually makes unibyte strings out of pure ASCII characters.