I have a JSON file where Unicode characters are encoded as UTF-8 codepoints, example: \u05de instead of the Hebrew character Mem (מ). How could I get emacs to display glyphs instead of the codepoint numbers?

Value of buffer-file-coding-system is currently utf-8-unix.

  • Just use a font that can show the glyphs of the chars you are interested in. IOW, change the font you're using. (Some people have recommended Symbola font for Unicode chars.)
    – Drew
    Jun 17 '18 at 14:48
  • This question looks like it might be a duplicate. Perhaps someone can check?
    – Drew
    Jun 17 '18 at 14:49
  • Note: I am using emacs in a virtual machine console without an X-Windows server. In regular files I am successful in viewing Unicode glyphs. But I would also like to see the characters when they are are 'spelled out' as codepoints.
    – ChaimKut
    Jun 18 '18 at 9:44
  • If you are interested in using the buffer-display-table, then here is an example: emacs.stackexchange.com/a/9627/2287 This will modify the appearance, but not the text itself.
    – lawlist
    Jun 20 '18 at 0:12

Not clear if you want this to be done "on the fly" as part of the rendering or if you'd be OK with modifying the buffer.

If the latter, then something like:

(defun sm-replace-codepoints ()
  (goto-char (point-min))
  (while (re-search-forward "\\\\u[:xdigit:][:xdigit:][:xdigit:][:xdigit:]" nil t)
    (replace-match (string (read-from-string (concat "?" (match-string 0)))))))

might do the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.