Re: Uppercase character predicate

Eli Zaretskii <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> From: Nikolaos Chatzikonstantinou <[email protected]>
> Date: Thu, 13 Aug 2026 23:08:40 -0400
> 
> Hello list,
> 
> I tried using the `char-uppercase-p' with the MATHEMATICAL FRAKTUR
> CAPITAL A character (unicode #x1d504) but it evaluated to nil. I
> peeked through `describe-char' to see how it comes up with the
> description above (since I can use it to detect if a character is
> capital) and I came up with this:
> 
>   (defun my/upcase-p (ch)
>     "Check if CH is uppercase.
> 
>   Slower, but more accurate than `char-uppercase-p'."
>     (string-match-p "CAPITAL"
>                     (get-char-code-property ch 'name)))
> 
> This function works for my needs, but why doesn't `char-uppercase-p'
> evaluate to true for this character?

Because Emacs considers a character to be uppercase only if there's a
corresponding lowercase character which makes the upper-/lower-case
pair.  And MATHEMATICAL FRAKTUR CAPITAL A doesn't have a corresponding
lowercase character.

And even if you want to get rid of that prerequisite, for some reason,
your implementation is incorrect.  You should do this instead:

    (defun my/upcase-p (ch)
      "Check if CH is an uppercase character."
      (eq 'Lu (get-char-code-property ch 'general-category)))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.