开发者

How to ensure all VS code files are in UTF-8?

开发者 https://www.devze.com 2023-01-13 13:18 出处:网络
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 t

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 $_ }
0

精彩评论

暂无评论...
验证码 换一张
取 消