emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs-26 8f18d12: Improve documentation of decoding into a unibyte b


From: Eli Zaretskii
Subject: Re: emacs-26 8f18d12: Improve documentation of decoding into a unibyte buffer
Date: Tue, 28 May 2019 18:18:07 +0300

> From: Stefan Monnier <address@hidden>
> Cc: address@hidden
> Date: Tue, 28 May 2019 07:55:40 -0400
> 
> >> Hence according to my reading of the code, this call to
> >> string-as-unibyte will always just return its argument unchanged.
> > That's not entirely true, because encode-coding-char can return a multibyte
> > string.
> 
> That's weird.  When would that happen?

"Use the source, Luke!"

  (let* ((str1 (string-as-multibyte (string char)))
         (str2 (string-as-multibyte (string char char)))
         (found (find-coding-systems-string str1))
        enc1 enc2 i1 i2)
    (if (and (consp found)
             (eq (car found) 'undecided))
        str1  <<<<<<<<<<<<<<<<<<<<<<<<<

If we return here, the value is str1, which is a multibyte string, see
how it was calculated.

The easiest use case is this:

  (multibyte-string-p (encode-coding-char ?a 'utf-8))
    => t

I didn't think enough about this to figure out if there can be less
trivial use cases.  If you can describe all the cases where
find-coding-systems-string will return a list whose 'car' is
'undecided', my hat off to you.



reply via email to

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