问题
When I insert an — (em dash) into a text file, Emacs initially displays it fine. When I reload Emacs, all instances of — are displayed as \342\200\224.
How can I get Emacs to display the characters as it did initially? I'm using Windows 7 and Emacs 24.3.1. The major mode is "Text" and minor is "Fill".
回答1:
Try inserting this into your init file. It should make sure emacs saves files as Unicode (and reads them correctly afterwards).
;;;;;;;;;;;;;;;;;;;;
;;; set up unicode
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
I'm fairly certain most of these options are unnecessary, but after inserting them I never had encoding problems again. Better safe than sorry. :-)
来源:https://stackoverflow.com/questions/17534750/emacs-not-displaying-unicode-on-reload