Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Emacs 開啟檔案亂碼?兩招搞定編碼自動偵測與手動重讀

編輯:關於 Linux

現象

Emacs 開啟 GB2312/GBK 編碼檔案時顯示亂碼,因預設以 UTF-8 或 Latin-1 解讀。

方法一:手動指定編碼重讀

  1. C-x RET r(即 M-x revert-buffer-with-coding-system)
  2. 輸入編碼名稱(如 gb18030-unix、gb2312),按 Tab 可自動補全。

方法二:安裝 unicad 自動偵測

  1. 下載 unicad.el 放入 ~/.emacs.d/my-elisp/(或任意 load-path 目錄)。
  2. ~/.emacs 加入:(require 'unicad)
  3. 重啟 Emacs,之後開啟檔案自動識別編碼。

結語

臨時用手動重讀,長期建議裝 unicad 讓 Emacs 智慧判斷編碼,徹底告別亂碼。

Copyright © Windows教程網 All Rights Reserved