English 中文(简体)
How do I make emacs display a multi-byte encoded file, properly? Is it mule?
原标题:

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

alt text

最佳回答

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.

问题回答

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 ?

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.





相关问题
Why are there duplicate characters in Unicode?

I can see some duplicate characters in Unicode. For example, the character C can be represented by the code points U+0043 and U+0421. Why is this so?

how to extract characters from a Korean string in VBA

Need to extract the initial character from a Korean word in MS-Excel and MS-Access. When I use Left("한글",1) it will return the first syllable i.e 한, what I need is the initial character i.e ㅎ . Is ...

File open error by using codec utf-8 in python

I execute following code on windows xp and python 2.6.4 But it show IOError. How to open file whose name has utf-8 codec. >>> open( unicode( 한글.txt , euc-kr ).encode( utf-8 ) ) Traceback ...

UnicodeEncodeError on MySQL insert in Python

I used lxml to parse some web page as below: >>> doc = lxml.html.fromstring(htmldata) >>> element in doc.cssselect(sometag)[0] >>> text = element.text_content() >>>...

Fast way to filter illegal xml unicode chars in python?

The XML specification lists a bunch of Unicode characters that are either illegal or "discouraged". Given a string, how can I remove all illegal characters from it? I came up with the following ...

热门标签