views:

126

answers:

3

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

alt text

A: 

It looks like the file is in Unicode UTF-16 or a similar two-byte encoding. The ^@ seem to be nulls in the contents. I don't think this has anything to do with Mule. Emacs is highly sensitive to file encoding errors, and even one byte wrong will throw it, so the file is probably misencoded somehow. An obvious way to solve this problem is to open the file in another editor and save it in a readable encoding.

Kinopiko
ok, so how do I view it? If I use notepad2, i can see the text just fine.
Cheeso
How about saving it in a different encoding?
Kinopiko
it's not about saving, it's about emacs not picking the right encoding on load.
Bahbar
I meant save it in a different encoding in notepad.
Kinopiko
ah, ok. That could work for this one file if that's the only issue.
Bahbar
very sneaky - you changed your answer after I asked my follow-up question.
Cheeso
What follow-up question?
Kinopiko
Also what on earth was that downvote for?
Kinopiko
+3  A: 

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 ?

Bahbar
Yes, the file has a BOM.
Cheeso
A: 

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.

pajato0