help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: More confusion about multibyte vs unibyte strings


From: Eli Zaretskii
Subject: Re: More confusion about multibyte vs unibyte strings
Date: Thu, 05 May 2022 20:34:54 +0300

> 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?



reply via email to

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