Subject: Re: bug#30458: 26.0; `ucs-names': No reverse lookup function now

From: Andy Moreton <[email-masked]>
Date: Wed, 14 Feb 2018 19:04:11 +0000

On Wed 14 Feb 2018, Drew Adams wrote:

> Before Emacs 26, `ucs-names' was an alist.  That meant that you could
> not only look up a character, given its name or code, but you could also
> easily look up a character name, given the character:
>
> (car (rassq CHARACTER (ucs-names)))
>
> How is this done now, with (ucs-names) returning a hash table?
>
> There is now a function `char-from-name', to replace the former forward
> alist lookup (car (assoc CHAR-NAME (ucs-names))).  But there doesn't
> seem to be any reverse lookup now for `ucs-names' (e.g. `char-name' or
> `char-name-from-char').

Looking at the implementation of ucs-names, does get-char-code-property
do what you want ?

  (char-from-name "GREEK SMALL LETTER LAMBDA")
      => 955

  (char-from-name "GREEK SMALL LETTER LAMDA")
      => 955

  (get-char-code-property 955 'name)
      => "GREEK SMALL LETTER LAMDA"

  (get-char-code-property 955 'old-name)
      => "GREEK SMALL LETTER LAMBDA"

HTH,

    AndyM