Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2017 Code Review "These files have different encodings" How do I fix this?

I'm reviewing comments on a Code Review using VS2017, the file is a CS file. Everytime I double click on the comment to see the comparisons on the source server vs. my local changes, an error shows up as follows:

"These files have differernt encodings. Left File: Western European (Windows). Right File: Unicode (UTF-8). Click Here

Different Encodings

I have attempted to no avail: 1) Closing and reopening the file using the Western Encoding (Windows) both code page 1252 and 800. 2) Saving the files using the Western Windows Encoding. 3) Closing and reopening Visual Studio.

Bottom Line is that the code review comparison page will not work until the two codepages match.

The last thing I did to this file prior to this error is to highlight all the text, Edit/Advanced/Tabbify Selected Lines to convert spaces to tabs. Could be root cause but not sure how to fix?

Any ideas?

like image 346
JWP Avatar asked Oct 02 '17 16:10

JWP


Video Answer


1 Answers

Simplest solution seems to be opening and saving files with an editor which is more reasonable with it's encoding handling and selecting UTF-8 no BOM which is recommended. After that, the error should be gone.

Notepad++ has an extensive top level menu Encoding which has commands to convert file to UTF-8 with no BOM or many other supported formats (ASCII, UTF-8, UTF-8 BOM, UCS-2 BE BOM, UCS-2 LE BOM).

The other problem could be a configuration of a source server (or lack of one) which would than send data over http/https connection using non UTF-8 encoding i.e. Western European (Windows) or whatever code page which is different from your local file. I would set server encoding explicitly to UTF-8.

Final check: clone repo locally and try to do a code review against local clone and if errors occur apply first method to repo file and check it in.

like image 192
Jacek Blaszczynski Avatar answered Oct 15 '22 11:10

Jacek Blaszczynski