Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save all files in Visual Studio project as UTF-8

I wonder if it's possible to save all files in a Visual Studio 2008 project into a specific character encoding. I got a solution with mixed encodings and I want to make them all the same (UTF-8 with signature).

I know how to save single files, but how about all files in a project?

like image 661
jesperlind Avatar asked Nov 11 '08 00:11

jesperlind


People also ask

How do I change the default encoding in Visual Studio?

Now open one of your files in Visual Studio. To verify its saving as UTF-8 go to File > Save As, then under the Save button choose "Save With Encoding". It should choose "UNICODE (Save without Signature)" by default from the list of encodings.


1 Answers

Since you're already in Visual Studio, why not just simply write the code?

foreach (var f in new DirectoryInfo(@"...").GetFiles("*.cs", SearchOption.AllDirectories)) {   string s = File.ReadAllText(f.FullName);   File.WriteAllText (f.FullName, s, Encoding.UTF8); } 

Only three lines of code! I'm sure you can write this in less than a minute :-)

like image 166
Timwi Avatar answered Sep 18 '22 23:09

Timwi