粘贴中文出的,这个是什么问题
These default coding systems were tried to encode text
in the buffer ‘elisp.el’:
(utf-8-dos (7566 . 4194260) (7567 . 4194265))
However, each of them encountered characters it couldn’t encode:
utf-8-dos cannot encode these:
Click on a character (or switch to this window by ‘SPC w C-w’
and select the characters by RET) to jump to the place it appears,
where ‘SPC u g a’ 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 no-conversion
选择了 utf-8 也是粘贴后还是 \324 \331
尝试粘贴 我
字 粘贴出来就是 \316\322
lisp 都识别这个是我
字
查看 evil-register 也是
我已经试过
;;use unicode everywhere
(when (fboundp 'set-charset-priority)
(set-charset-priority 'unicode))
(prefer-coding-system 'utf-8-unix)
(modify-coding-system-alist 'process "*" 'utf-8-unix)
(set-buffer-file-coding-system 'utf-8-unix)
(set-file-name-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(set-keyboard-coding-system 'utf-8-unix)
(set-terminal-coding-system 'utf-8-unix)
(set-language-environment "UTF-8")
(setq locale-coding-system 'utf-8-unix)
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
(when (eq system-type 'windows-nt)
(setq locale-coding-system 'chinese-gbk))
;;The clipboard on windows dose not play well with utf8
(unless (eq system-type 'windows-nt)
(set-clipboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8))
(setq system-time-locale "C")
SPQR
2022 年1 月 7 日 12:44
4
你是windows系统吗?试试这个行不行
(setq default-process-coding-system '(gbk-dos . gbk-dos))
(setq locale-coding-system 'gbk-dos)
(setq selection-coding-system 'utf-16le-dos)
(set-default 'process-coding-system-alist
'(("[pP][lL][iI][nN][kK]" utf-8-dos . gbk-dos)
("[cC][mM][dD][pP][rR][oO][xX][yY]" gbk-dos . gbk-dos)
("*" utf-8-unix . utf-8-unix)))
应该是编码问题,我在Windows 上这样设置,一切正常。
还有操作系统的区域设置,建议你也看看。
日期格式最好改成英文格式。
自己试了 Pasting Text from Clipboard - why ^M instead of linebreaks? 后 正常了
(if (eq system-type 'windows-nt)
(progn
(set-clipboard-coding-system 'utf-16-le)
(set-selection-coding-system 'utf-16-le))
(set-selection-coding-system 'utf-8))
(prefer-coding-system 'utf-8-unix)
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8-unix)
(set-terminal-coding-system 'utf-8-unix)
(set-keyboard-coding-system 'utf-8-unix)
(setq locale-coding-system 'utf-8-unix)
;; Treat clipboard input as UTF-8 string first; compound text next, etc.
(when (display-graphic-p)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
2 个赞