12

Windows 10, Emacs 25.

When I want to convert file from Windows-1251 to UTF-8 I use Notepad++.

Before convert:

enter image description here

convert:

enter image description here

after convert:

enter image description here

My question is: Is it possible this convert in Emacs?

Braiam
  • 103
  • 5
Alex
  • 781
  • 2
  • 7
  • 18

3 Answers3

11

One should use the command set-buffer-file-coding-system (C-x RET f), set the encoding, and then save the file.

Note that you may want to first revert-buffer-with-coding-system (C-x RET r) before performing the above step, if the file is opened with the wrong encoding in the first place.

xji
  • 2,545
  • 17
  • 36
5

The easiest way to do this is to:

  1. Type C-x RET c
  2. Select the desired coding system (in this case probably utf-8-dos)
  3. Pass C-x C-w as the command and pass the name of the file to write
2

This should do the trick:

  1. Visit the file with C-x C-f.
  2. Revert opened buffer to the original file encoding (cp-1251 in this case) with M-x + revert-buffer-wth-coding-system.
  3. Use M-x + set-buffer-file-coding-system to set encoding to utf-8.
  4. Save the file.
wotopul
  • 21
  • 2