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

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

More confusion about multibyte vs unibyte strings


From: Eric Abrahamsen
Subject: More confusion about multibyte vs unibyte strings
Date: Thu, 05 May 2022 09:58:43 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

In gnus-search.el, we do some work on search strings before sending them
to an IMAP server as a query: there are particular formats that need to
be used depending on whether the string is plain ASCII, or needs to be
encoded as UTF-8 or something. From the code itself:

(gnus-search-imap-handle-string
 (make-instance 'gnus-search-imap :literal-plus t)
 "FROM eric")

-> "FROM eric"

(gnus-search-imap-handle-string
 (make-instance 'gnus-search-imap :literal-plus t)
 "FROM 张三")

-> "{11+}
FROM \345\274\240\344\270\211"

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.

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? And what check
*should* I be using to see if a string is pure ASCII?

Thanks,
Eric




reply via email to

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