From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: More confusion about multibyte vs unibyte strings
Date: Thu, 05 May 2022 20:34:54 +0300 [thread overview]
Message-ID: <83zgjv288x.fsf@gnu.org> (raw)
In-Reply-To: <874k23or0c.fsf@ericabrahamsen.net> (message from Eric Abrahamsen on Thu, 05 May 2022 09:58:43 -0700)
> From: Eric Abrahamsen <eric@ericabrahamsen.net>
> 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?
next prev parent reply other threads:[~2022-05-05 17:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 16:58 More confusion about multibyte vs unibyte strings Eric Abrahamsen
2022-05-05 17:34 ` Eli Zaretskii [this message]
2022-05-05 18:44 ` Eric Abrahamsen
2022-05-05 19:23 ` Eli Zaretskii
2022-05-06 0:45 ` Eric Abrahamsen
2022-05-06 2:58 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-05-06 16:45 ` Eric Abrahamsen
2022-05-06 17:39 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-05-06 18:02 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83zgjv288x.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).