Home visual-studio Encoding in Visual Studio, how to enable utf-8?

Encoding in Visual Studio, how to enable utf-8?

Author

Date

Category

Is there a way to change the file encoding in Visual Studio on UTF-8? So that it was on an ongoing basis. I found only one way, but it changes the encoding of only one file from (for example) hundreds of already existing. This

File - & gt; Advanced Save Options
and in the encoding list choose UTF-8


Answer 1, Authority 100%

To automatically save to UTF-8 all new files containing characters other than the ASCII set, you must enable the option – Tools & GT; Options & gt; Environment & GT; Documents & GT; Save Documents As Unicode WHEN DATA CANNOT BE SAVED IN CODEPAGE


Answer 2, Authority 62%

Taken from Enso :

times you are in Visual Studio, then why not write code?

foreach (var f in new directoryinfo (@ "..."). GetFiles ("*. CS", SearchOPTION. ALLDIRECTORIES)) {
 String S = file.ReadALLTEXT (FullName);
 File.WriteAllText (FullName, S, Encoding.UTF8);
}

and from there the same option for PowerShell:

function write-utf8 ([String] $ Path, [String] $ Filter = '*. *')
{
  [Io.Searchoption] $ option = [io.Searchoption] :: Alldirectories;
  [String []] $ Files = [io.directory] :: getfiles ((Get-Item $ Path) .FullName, $ Filter, $ Option);
  Foreach ($ File in $ Files)
  {
    "Writing $ File ...";
    [String] $ s = [io.file] :: ReadALTEXT ($ File);
    [Io.file] :: WriteAlltext ($ File, $ s, [text.encoding] :: utf8);
  }
}

Answer 3, Authority 25%

Change with NotePad ++
open the file via NotePad ++ – & gt; Choose the encoding point – & gt; Change what you need
I helped!


Answer 4, Authority 25%

File – & gt; Settings – & gt; Parameters – & gt; Text editor – & gt; Files – & gt; Auto Guess Encoding – & gt; True


Answer 5, Authority 25%

helped me:

#pragma execution_character_set ("UTF-8")

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions