2011-11-19

Enter Unicode by Decimal

Here's a piece of code that lets you inpute unicode by its decimal number

(defun replace-current-word-as-decimal-unicode-char ()
  "Replace current word as decimal number by a corresponding Unicode character.
If there's a text selection, use that as input."
  (interactive)
  (let (bds p1 p2 inputStr )
    (if (region-active-p)
        (progn
          (setq p1 (region-beginning))
          (setq p2 (region-end)) )
      (progn
        (setq bds (bounds-of-thing-at-point 'word)  )
        (setq p1 (car bds))
        (setq p2 (cdr bds)) ) )

    (setq inputStr (buffer-substring-no-properties p1 p2)  )

    (delete-region p1 p2 )
    (ucs-insert (string-to-number inputStr) ) ) )