Elisp: Character Type

By Xah Lee. Date: .

In emacs lisp, character is represented as integer of the character's Unicode code point.

For example, the char a in elisp is just 97, because its code point is 97.

Note: elisp “Character Type” is not technically a “type” of value in the sense of most programing languages, because there's no way to distinguish integer from char. There is no function that returns true/false on whether a value is a character type. (by comparison, there are stringp, integerp, listp, symbolp, etc.) Whether a integer is a character depends on where it is used.

Char Syntax

Char can also be represented like this ?a for easy reading. ?a means the character a.

You can also represent char by (string-to-char "a")

(equal 97 ?a ) ;; t
(equal 97 (string-to-char "a")) ;; t

Find a Char's Code Point

To find a char's code point, Alt+x describe-char.

ASCII Control Chars and Backslash

Syntax of the form

?\char

May have special meaning, depending what char is.

for example, ?\n is the newline char. ?\\ is backslash char.

They either represent a ASCII control character, or just the character char.

Here's a list of special meaning with the backslash:

[see ASCII Table]

Reference

(info "(elisp) Character Type")

(info "(elisp) Basic Char Syntax")

Elisp Syntax Table

  1. Character Type
  2. Syntax Table Tutorial
  3. Find Syntax of a Character
  4. Modify Syntax Table Temporarily
  5. is Cursor Inside String/Comment
  6. Regex Patterns and Syntax Table
  7. Find Matching Bracket Char

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc