unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* More confusion about multibyte vs unibyte strings
@ 2022-05-05 16:58 Eric Abrahamsen
  2022-05-05 17:34 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2022-05-05 16:58 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-06 18:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-05 16:58 More confusion about multibyte vs unibyte strings Eric Abrahamsen
2022-05-05 17:34 ` Eli Zaretskii
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

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).