4

I have a file in my C: drive on Windows named MSDELog.log and from opening the file with a hex editor I can see that there is a null character after each character. But there is no indicator at the start of the file saying unicode or whatever the encoding is.

If I open this file with the Windows notepad it seems to recognise it and opens correctly.

If I open the file in emacs I see the text but every other character is ^@ - I realise this indicates a null character.

If I hit m-x revert-buffer-with-coding-system and try utf-8 there is no change in the view. If I select utf-16 then I see a load of what looks like Chinese characters.

How do I view this file in emacs?

1 Answer 1

7

It's a file encoded in utf-16 little endian format without the byte order mark. You have to specify the endianness selecting utf-16-le when you use revert-buffer-with-coding-system

2
  • I wondered what le meant
    – arcomber
    Commented Nov 21, 2020 at 17:45
  • LE means Little Endian. If the coding is not LE then BE, which means Big Endian. Commented Jul 7, 2022 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.