Windows 10 (64 bit), Emacs 25.1

I want when I save any file to save them (by default) with coding system = UTF-8.

So In my init.el I has :

(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-language-environment 'utf-8)
(set-selection-coding-system 'utf-8)

But it not help. When I try to save file (C-x C-s) Emacs prompt me: "Select coding system"

  • 1
    What is the type/mode of the file you are saving? Having you tried this with just emacs -Q? I just have (prefer-coding-system 'utf-8-unix) in my config (Windows 10, Emacs 25.2) and it works fine. Your code also seems fine, so it is likely something else. Jul 21, 2017 at 10:39
  • Type mode is Text because file is myfile.txt. I try this (prefer-coding-system 'utf-8-unix) - but it not help. I try emacs -Q but it also ask me "Select coding system".
    – Alex
    Jul 21, 2017 at 11:49
  • That is strange. What language is Windows 10 configured to use - for input etc - and what kind of characters (e.g. Latin, Cyrillic, Chinese) does your text file contain? PS. I didn't mean to suggest you should use 'utf-8-unix, utf-8 should be fine. Jul 21, 2017 at 13:14
  • Also - what does "myfile.txt" contain? Text you typed in? Nothing? Text pasted in? Jul 21, 2017 at 13:23

3 Answers 3


This does it for me:

(set-language-environment "UTF-8")

See here.


I do not know if this can be of help, but I will mention it anyway. When working (mainly in source LaTeX files) with my colleagues who use a different coding system, nothing I did could persuade Emacs to always read (or save) with the desired encoding. I found that the only safe way was to add as a first line something like:

% -*- coding: iso-8859-15 -*-

starting in column 1. You can set the encoding you prefer there, and Emacs will save (or read) with the prescribed encoding.


You could try M-x customize then Environment > Keyboard > Keyboard Coding System The docs say "This is set at startup based on locale." which may also point you in the direction of what variable to set.

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.