Filename in chinese shows as unicode characters

[Origin]: http://stackoverflow.com/questions/17961148/filename-in-chinese-shows-as-unicode-characters

when using C-x C-f, the filename which includes Chinese characters are shown as following:

How can I configure it to show Chinese words? Thank you.

=====updated=======

System: OS X 10.8.4

Emacs version: GNU Emacs 24.3.1 (x86_64-apple-darwin)

shareedit

I think this may be caused by one of those annoying interactions between the operating system and Emacs. Emacs doesn’t seem to know how to interpret the file names, so let’s try to help it by inserting this in your .emacs file.

(setq default-buffer-file-coding-system 'utf-8-unix)
(setq default-file-name-coding-system 'gb2312)
(setq default-keyboard-coding-system 'utf-8-unix)
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))

You may need to try a different system instead of gb2312.

shareedit

Emacs复制粘贴乱码问题以及修改当前文件编码

【转载】:http://www.cnblogs.com/ilfmonday/p/emacscoding.html

编码修改:

为了和Linux兼容,win环境下将emacs编码修改为utf-8,随意复制了其他关于emacs编码的配置,如下:

(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)

问题与解决:

结果发现emacs和其他win的窗口进行相互的复制粘贴时出现问题,表现为当从其他窗口复制文字,粘贴到emacs中,出现乱码(\xxx这种形式)。细读手册,发现:

selection-coding-system

这个变量用于控制emacs和其他窗口相互发送接收文本的编码,应该就是这个变量的问题,因此在配置文件中将这个变量注释掉,问题解决。

(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;;(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)

修改当前文件编码:

emacs打开一个文件修改后存储时,会默认使用文件的当前编码存储。如果想更换另外一个编码,可以:

C-x RET c "utf-8" RET C-x C-w RET
;;1 universal-coding-system-argument
;;2 immediately following command 文件另存为

这种交互的方式完成