I has some sybmol, e.g. O and I want to convert it to hex value. The result must be 4f
How I can do this in Emacs 26.1 ?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
You can simply run M-x
eval-expression and type
?O. You will get the following output in the minibuffer:
79 (#o117, #x4f, ?O)
Maybe no so elegant but should do the trick. Note I have assigned it to "C-." which might be used by other functions in your setup. Reassign as you wish:
(defun hexify() (interactive) (setq hx (format "%x" (char-before))) (delete-backward-char 1) (insert hx)) (global-set-key (kbd "C-.") 'hexify)
Calling the function, replaces the character before the cursor with its hex. If you just want the value Arkadiusz's answer will do.