1

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.

4
  • 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, 2018 at 14:48
  • This question looks like it might be a duplicate. Perhaps someone can check?
    – Drew
    Jun 17, 2018 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, 2018 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, 2018 at 0:12

1 Answer 1

1

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 ()
  (interactive)
  (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 and acknowledge you have read our privacy policy.

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