Function: text-char-description

text-char-description is a function defined in keymap.c.

Signature

(text-char-description CHARACTER)

Documentation

Return the description of CHARACTER in standard Emacs notation.

CHARACTER must be a valid character code that passes the characterp test. Control characters turn into "^char", and characters with Meta and other modifiers signal an error, as they are not valid character codes. This differs from single-key-description which accepts character events, and thus doesn't enforce the characterp condition, turns control characters into "C-char", and uses the 2**27 bit for Meta. See Info node (elisp)Describing Characters for examples.

View in manual

Source Code

// Defined in /usr/src/emacs/src/keymap.c
{
  CHECK_CHARACTER (character);

  int c = XFIXNUM (character);
  if (!ASCII_CHAR_P (c))
    {
      char str[MAX_MULTIBYTE_LENGTH];
      int len = CHAR_STRING (c, (unsigned char *) str);

      return make_multibyte_string (str, 1, len);
    }
  else
    {
      char desc[4];
      int len = push_text_char_description (c, desc) - desc;
      return make_string (desc, len);
    }
}