Re: `read-from-minibuffer' seems to always return a multibyte string, but why?
Nickolai Dobrynin <[email protected]>
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Eli Zaretskii <[email protected]> writes: >> >> By the way, a multibyte string was really what I wanted out of this. I >> >> just want to be sure that this behavior is not accidental. >> > >> > Why do you care, may I ask? >> >> I've been looking at `gnus-search-make-spec' in gnus-search.el and >> asking myself what kind of string this function returns. The final >> argument in the call to `read-from-minibuffer' defaults to nil. I must >> have understood the meaning of that argument in reverse. > > OK, but still: why did you care whether gnus-search-make-spec returns > a unibyte or a multibyte string? That goes back to our recent discussion at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=81684 First, before converting to UTF8, I wanted to know what is it that I am dealing with, i.e. whether uni- or multibyte strings are involved. Second, per your suggestion that there may be bugs that are exposed after a new feature is added, I asked myself: am I getting a multibyte string from `read-from-minibuffer' because this is what is SUPPOSED to happen, or this is due to an existing bug? Then I looked at how that function was being called and got an impression that I should have been getting a unibyte string back instead. This prompted my original question. > You see, usually functions that return strings to the application > level (including UI) should always return multibyte strings when > non-ASCII characters are involved, and either multibyte or unibyte > strings when only ASCII characters are involved. Anything else is > either a bug or a very special situation. Of course. This is a core principle. And this is the behavior I was expecting. I am glad that this principle is being followed here. That makes the UTF8 conversion much easier. Hope this makes more sense now. One question remains, though: what is the mechanism by which `read-from-minibuffer' is returning a multibyte string here? Since `inherit-input-method' is nil, the minibuffer, according to the manual, does NOT inherit the current input method and the multibyteness of the previous current buffer. This description makes it sound like setting the final argument to nil places the function in the unibyte mode. I know, I'm wrong, but where exactly am I wrong? Many thanks.