Question

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

alt text

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top