How do I know what encoding should be applied to a file in Intellij Idea?

I had a file in which some of the comments in Russian were displayed normally, some were not recognized:

enter a description of the image here

Then the file had the encoding windows-1251. After I changed the file encoding to UTF-8, all comments became unreadable:

enter a description of the image here

How do I find out what encoding a file should have? I.e., maybe there are some algorithms like:

enter a description of the image here

Author: Ksenia, 2016-08-30

1 answers

Ideally, the encoding is usedUTF-8.

If you want to save a file in UTF-8 with comments, but without rewriting them:
You can restore the encoding Windows-1251, select all, cut, change the encoding to UTF-8 , and paste the cut. This way you will have a file in the format UTF-8 and the comments will be saved in Cyrillic.

For decoding, you can use this service.

 1
Author: Legionary, 2016-08-30 14:08:25