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 20:34:54 +0300 Message-ID: <83zgjv288x.fsf@gnu.org> References: <874k23or0c.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="358"; 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 20:02:12 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 1nmfno-000AQY-28 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 05 May 2022 20:02:12 +0200 Original-Received: from localhost ([::1]:59376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmfnn-0004mC-0X for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 05 May 2022 14:02:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmfNk-0007Gp-PK for help-gnu-emacs@gnu.org; Thu, 05 May 2022 13:35:17 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmfNk-0006YB-G9 for help-gnu-emacs@gnu.org; Thu, 05 May 2022 13:35:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=XoBTZE6T39OyLaRqXsZwqMR+PQgGExBr2SkrJ9IpcQY=; b=CnEruxcQTWdOzHJI+IEZ ToLkKuEncnaaXeN2s7VObZ81af+OmrKZD0KrLZDSYOMTKdQ+Pio00PbE97YLOpkGYrXPuzALOslRH Z0o/+Ip3sA8kJI33yjJQsQnFckNY+tngXTUooI3fVZ5XK1pocdSUhgKzUyf7B/X/6iS7oWCpI+aCv F20OOgFGdQ6kNX3QP7/SJ/x209aLRfjJJHf4M0GP+p+Jd+1qnXXpNE2o6qZ8IJufAf82dQbFlgV3k 1IbeZaE+S7TNSUaLLicT2/WInDCKxrLeecofS3wN2iKQXqvA85yGWghzEXFn7dWFfZL5C7W5uFdae taK4llSaq9g2Uw==; Original-Received: from [87.69.77.57] (port=4207 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 1nmfNc-0000Z7-UX for help-gnu-emacs@gnu.org; Thu, 05 May 2022 13:35:16 -0400 In-Reply-To: <874k23or0c.fsf@ericabrahamsen.net> (message from Eric Abrahamsen on Thu, 05 May 2022 09:58:43 -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:137150 Archived-At: > From: Eric Abrahamsen > Date: Thu, 05 May 2022 09:58:43 -0700 > > The function above uses `multibyte-string-p' to test whether the string > needs the extra handling. This works correctly in the minibuffer and > *scratch*: > > (multibyte-string-p "FROM eric") -> nil > > (multibyte-string-p "FROM 张三") -> t > > but when I edebug the code during an actual IMAP search, the test > returns t for both strings, which messes things up. 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. > I must be using it wrong! But I don't understand why. What can change in > the evaluation environment such that the calls to `multibyte-string-p' > would return different results at different times? Any number of string operations can convert a pure-ASCII string into a multibyte string. The most frequent one is decode-coding-string. Again, why should this be a problem for your code? > And what check *should* I be using to see if a string is pure ASCII? Why do you care?