AsciiTable

You can use ‘M-x man RET ascii RET’ on most systems. There is a man page with the ASCII table and code points in decimal, hexadecimal, and octal.

You may also use ‘M-x list-charset-chars’. It is often too limited, however.

In that case, use the following:

Install by adding to your ~/.emacs file:

    (autoload 'ascii-table "ascii-table" "Show ASCII table." t)

There are commands for octal, decimal, and hexadecimal codes.

Rick Bielawski uses the following:

  (defun ascii-table ()
    "Display basic ASCII table (0 thru 128)."
    (interactive)
    (switch-to-buffer "*ASCII*")
    (erase-buffer)
    (setq buffer-read-only nil)        ;; Not need to edit the content, just read mode (added)
    (local-set-key "q" 'bury-buffer)   ;; Nice to have the option to bury the buffer (added)
    (save-excursion (let ((i -1))
      (insert "ASCII characters 0 thru 127.\n\n")
      (insert " Hex  Dec  Char|  Hex  Dec  Char|  Hex  Dec  Char|  Hex  Dec  Char\n")
      (while (< i 31)
        (insert (format "%4x %4d %4s | %4x %4d %4s | %4x %4d %4s | %4x %4d %4s\n"
                        (setq i (+ 1  i)) i (single-key-description i)
                        (setq i (+ 32 i)) i (single-key-description i)
                        (setq i (+ 32 i)) i (single-key-description i)
                        (setq i (+ 32 i)) i (single-key-description i)))
        (setq i (- i 96))))))

I like Rick’s solution.


A variation on on the above that displays codes for the lower 32 values:

  (defun ascii-table ()
      "Display basic ASCII table (0 thru 128)."
      (interactive)
     (switch-to-buffer "*ASCII*")
      (erase-buffer)
      (setq buffer-read-only nil)        ;; Not need to edit the content, just read mode (added)
      (local-set-key "q" 'bury-buffer)   ;; Nice to have the option to bury the buffer (added)
      (setq lower32 '("nul" "soh" "stx" "etx" "eot" "enq" "ack" "bel"  
  		    "bs" "ht" "nl" "vt" "np" "cr" "so" "si"
  		    "dle" "dc1" "dc2" "dc3" "dc4" "nak" "syn" "etb"
  		    "can" "em" "sub" "esc" "fs" "gs" "rs" "us"
  		    ))
      (save-excursion (let ((i -1))
      (insert "ASCII characters 0 thru 127.\n\n")
      (insert " Hex  Dec  Char|  Hex  Dec  Char|  Hex  Dec  Char|  Hex  Dec  Char\n")
      (while (< i 31)
        (insert (format "%4x %4d %4s | %4x %4d %4s | %4x %4d %4s | %4x %4d %4s\n"
                        (setq i (+ 1  i)) i (elt lower32 i)
                        (setq i (+ 32 i)) i (single-key-description i)
                        (setq i (+ 32 i)) i (single-key-description i)
                        (setq i (+ 32 i)) i (single-key-description i)))
        (setq i (- i 96))))))

See also


CategoryProgrammerUtils