Is there a way to ensure all code files in my Visual Studio solution are encoded in UTF-8? I'd prefer this done automatically rather than by hand. Thanks!
Asked
Active
Viewed 1,068 times
0
-
Is someone or something creating them in a different encoding? – Will A Aug 30 '10 at 16:50
-
http://stackoverflow.com/questions/279673/save-all-files-in-visual-studio-project-as-utf-8 – Chris Diver Aug 30 '10 at 16:54
1 Answers
1
Short answer - you can't do this in one automatic action, because there is no deterministic way of knowing that file has other encoding than UTF-8. Surely, you can say a lot for BOM, but there are cases in which file is in UTF but has no BOM at all.
Best way IMO is to always resave new file as UTF-8 (I assume you are using R# and experience results of RSRP-291502 bug).
You still can try semi-automatic action (see script below) and then check manually for corrupted results.
Powershell :
gci . -include *.cs -recurse | ForEach-Object { (Get-Content $_) | Out-File -Encoding UTF8 $_ }

head_thrash
- 1,623
- 1
- 21
- 26