Change file encoding without information losses in intellij idea

Sergey picture Sergey · Oct 20, 2011 · Viewed 11k times · Source

Is it possible to change file's encoding from UTF-8 to windows1251 without cyrillic information lost. Because when I explicitely change the encoding, all cyrillic symbols become unreadable?

Answer

CrazyCoder picture CrazyCoder · Oct 20, 2011

UPDATE: new IDE versions can convert encodings:


The problem is that IntelliJ IDEA doesn't actually convert your file encoding from UTF-8 to windows-1251, what happens is that you tell IntelliJ IDEA to treat UTF-8 file as being encoded in windows-1251, so you will see garbage in the editor. The actual file on disk remains in UTF-8.

You have to use some external tool to perform the conversion, such as iconv:

iconv.exe -f utf-8 -t windows-1251 <input file> > <output file>