How to ensure all VS code files are in UTF-8?
Is ther开发者_开发问答e 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!
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 $_ }
精彩评论