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.

ChaimKut
  • 187
  • 8
  • 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 09:44
  • If you are interested in using the `buffer-display-table`, then here is an example: https://emacs.stackexchange.com/a/9627/2287 This will modify the appearance, but not the text itself. – lawlist Jun 20 '18 at 00:12

1 Answers1

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.

Stefan
  • 26,154
  • 3
  • 46
  • 84