Emacs Not Displaying Unicode on Reload

☆樱花仙子☆ 提交于 2019-12-10 18:52:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!