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

enter image description here

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

enter image description here

How to find out what encoding the file should have? Ie, maybe there are some algorithms like:

enter image description here

  • @ArtemKonovalov, yes, I use online decoders from time to time, but I hoped that there was some 100% way to find out the correct (original) encoding for just one Intellij Idea file - Ksenia
  • one
    this is pure random in fact, all of these analyzers simply go through the encodings and check the correspondence of the frequency of appearance of characters in the text and the average frequency for a given language. They have a probabilistic nature. 100% nobody will give you. PS in idea I look for plug-ins of this kind not. - Artem Konovalov
  • If some comments are displayed correctly, while others are not, then there simply cannot be a mixture of encodings and one correct encoding. - Roman
  • @Roman is a very strange situation, but it can be very. - Artem Konovalov

1 answer 1

Ideally, UTF-8. encoding is used UTF-8.

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

For decoding, you can use this service.

  • And how do you know in which encoding there should be a lower comment that was originally in the wrong encoding? - Ksenia
  • @Ksenia Well, you say that your comments were correctly displayed in windows-1251 encoding. PS For the most part, if the encoding of the file changes to UTF-8 and there was Cyrillic, the characters are replaced with?. So try the method I described above. - Legionary
  • I wrote "some comments in Russian were displayed normally" :) - Ksenia
  • @Ksenia attached a link to the service to the response, which recognizes the text in an unknown encoding. Try using it to pick up. - Legionary
  • Is there no exact way to find out the correct (original) encoding for just one Intellij Idea file? - Ksenia