I use the Chinese Ubuntu, and the version of emacs is 23. When I copy chinese words to the Emacs, then there will be disordered codes and digital numbers. And when I use C-c C-s to save the file, then emacs will alert me to select one encoding-system as following:

These default coding systems were tried to encode text
in the buffer `12-07.org':
  (chinese-iso-8bit-unix (229 . 4194279) (230 . 4194203) (236
  . 4194281) (237 . 4194179) (239 . 4194238) (240 . 4194184) (241
  . 4194279) (242 . 4194182) (243 . 4194207) (244 . 4194278) (245
  . 4194178))
However, each of them encountered characters it couldn't encode:
  chinese-iso-8bit-unix cannot encode these: ç  é  ¾  ç   æ ...

Click on a character (or switch to this window by `C-x o'
and select the characters by RET) to jump to the place it appears,
where `C-u C-x =' will give information about it.

Select one of the safe coding systems listed below,
or cancel the writing with C-g and edit the buffer
   to remove or modify the problematic characters,
or specify any other coding system (and risk losing
   the problematic characters).

  raw-text emacs-mule no-conversion

How can I set the .emacs file to solve the problem? Now my .emacs file setting is as following:

;; Font setting
;; 设置两个字体变量,一个中文的一个英文的
;; 之所以两个字体大小是因为有的中文和英文相同字号的显示大小不一样,需要手动调整一下。
(setq cjk-font-size 18)
(setq ansi-font-size 18)

(prefer-coding-system 'utf-16-le)

;; EXPERIMENTAL: Set language environment
;;(setq current-language-environment 'latin-1)
;;(setenv 'latin-1)
;;(setenv LANG en_US.8859-1)

(set-language-environment "Latin-1")
(set-keyboard-coding-system 'latin-1)
(set-terminal-coding-system 'latin-1) 

(set-fontset-font "fontset-default" 'gb18030' ("STHeiti" . "unicode-bmp"))
;;(set-language-environment "Chinese-GB")
;;(set-keyboard-coding-system 'chinese-iso-8bit)

(global-set-key [?\S- ] 'set-mark-command)

;;设置默认字体
;;(set-default-font " 'gb18030')
;;(setq default-frame-alist "STHeiti")
;;(setq default-frame-alist (font . "微软雅黑Monaco 12"))

;; 恢复成默认大小17号
(defun default-font-size()
  "default font size"
  (interactive)
  (setq cjk-font-size 17)
  (setq ansi-font-size 17)
  (message "cjk-size:%d pt, ansi-size:%d pt" cjk-font-size ansi-font-size)
  (set-font)
  (sit-for .5))
1

There are 1 best solutions below

0
On

The problem is caused by the (set-language-environment "Latin-1")

You should leave the language environment alone so it is in sync with your system's locale. Also keyboard and terminal coding system should only be set if absolutely necessary, which may be the case if you mostly use Emacs remotely from a system with a different locale than the local one, but is not likely to be necessary if you only use Emacs locally.