How can VS determine the encoding of a file when we cannot?

According to several answers to SO, for example. How can I determine the encoding / encoding of a text file , it is not possible to get the encoding of a file.

How does VS do this then? If I Save As and select Save With Encoding, it will display the current encoding of my file.

+4
source share
1 answer

By default, the editor detects the encoding by looking for byte bytes or set tags. If none of them are found in the current document, the code editor attempts to automatically detect the UTF-8 encoding using sequences of scan bytes. Help VS

If VS cannot convert any sequence of bytes into valid Unicode characters, it opens the default file in the system character set. There is no magic.

+1
source

Source: https://habr.com/ru/post/1381448/


All Articles