How do I make emacs display a multi-byte encoded file, properly? Is it mule?

夙愿已清 提交于 2019-12-06 06:16:03

问题


When I open a multi-byte file, I get this:


回答1:


If memory serves, Emacs will prompt the User for an encoding if it cannot determine one. When it makes a wrong determination you can use

C-x RET f coding RET

which will use coding as the coding system for the visited file in the current buffer.




回答2:


Short term, you can revisit the file with an alternate coding system with revert-buffer-with-coding-system (select utf-16le then).

Middle term, you can bump the priority of that utf-16le encoding on load with prefer-coding-system.

Long term, however, you'd better try to understand why emacs did not pick the right encoding. I'm not sure how I can help there though, short of digging inside the coding system guts, or at least have a file to reproduce.

EDIT: Does this file have a BOM ?




回答3:


In xml files, Emacs takes this is big endian, while Windows takes this as little endian.

<?xml version="1.0" encoding="UTF-16"?>
<hi />

Trying something like encoding="UTF-16LE" or encoding="UTF16-16BE" will ruin the xml file after saving. It will take off the BOM. utf-16le no bom can be opened in Notepad.



来源:https://stackoverflow.com/questions/1707362/how-do-i-make-emacs-display-a-multi-byte-encoded-file-properly-is-it-mule

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