How can I setup Emacs to be able to display the content of an old file that contains non-ASCII 8-bit characters that we encoded using a code-page my system does not seem to support?

I have a file that has most probably been written in Germany in the days of 8-bit extended ASCII and Emacs does not display those characters properly. I was thinking I code tell Emacs to try various encoding and see if text would show up. Encoding like Windows 1250 code-page or some others.

Can this be done in Emacs?

  • You should also try iso-8859-1. C-x RET c iso8859-1 RET C-x C-f <filename> RET should open it with that coding system. The coding system is indicated on the mode line at left as 1: .With some experience, you can tell what coding system was used, when you open the file with M-x find-file literally or with od -c from the command line and looking at the non-ascii chars.
    – NickD
    Nov 2, 2021 at 21:02
  • The file I'm testing this with is a DOS-line termination file. It is identified as iso-8859-1. I presume that file was created with a pre-Unicode coding system most probably in a German speaking country.
    – PRouleau
    Nov 2, 2021 at 21:38
  • I found out that loading the file in Firefox detects the encoding, which turned out to be GBK (simplified chinese). Knowing the encoding I can then use the method you described to open the file with GBK encoding and then I can tried to read the Chinese just fine ;-)
    – PRouleau
    Nov 2, 2021 at 21:51
  • @Nick if you turn your answer in using the universal-coding-system-argument command into an answer I'll accept it.
    – PRouleau
    Nov 2, 2021 at 22:04
  • I'll try, but it's going to take me a few days: writing a good answer is different from throwing out crazy suggestions in a comment :-)
    – NickD
    Nov 3, 2021 at 3:34

1 Answer 1


M-x set-buffer-file-coding-system and select the desired coding system.

This is, by default, bound to C-x RET f.

Notice that C-x RET is a prefix map. For more info, C-x RET C-h (or equivalently C-x C-m C-h).

  • Thanks. The docstring of that command states Make CODING-SYSTEM used for communicating with other X clients. Is this only meant to be used on Emacs running in graphics mode over X-Windows, or is this just an obsolete description?
    – PRouleau
    Nov 2, 2021 at 20:28
  • After reading the docstring of set-selection-coding-system, it seems that X is relevant for clipboard support and related functionality. I can give a better answer, please check the edited version.
    – aadcg
    Nov 2, 2021 at 20:45

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.