Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up default encoding in Visual Studio 2010

We're using Visual Studio 2010 professional to develop and maintain our company ASP (classic ASP, not ASP.NET) e-commerce web site, and I'm having file encoding issues every time I create a new page.

Every page in our web site is saved as Windows-1252, and when I create a new page (or randomly when I modify an existing one) Visual Studio saves the page using the UTF-8 encoding, screwing up extended characters or #includes (since the included file is saved as Windows-1252 and the page including it is UTF-8, when displayed the included content goes haywire).

I've tried searching everywhere, but the only solution I found is "Save every file manually with "File" → "Save as" → "Save with encoding", which is quite an hassle to do every time (and I'm totally going to forget to do it sometime).

I already tried deselecting the option "Save documents as Unicode when data cannot be saved in codepage" in "Environment" → "Documents" settings but to no avail.

Am I really stuck with the manual thing?

like image 398
Albireo Avatar asked Dec 17 '10 09:12

Albireo


1 Answers

I'm way late answering this, but I had the issue myself and this is the first hit on google, so I'll document it here if anyone else wants to know. :)

The default encoding of a new file in Visual Studio depends on the template for that kind of file.

The JavaScript file template for instance recides in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Web\WebNewFileItems\JScript.js (on my box). If you edit that file and save it with your encoding of choice, all new javascript files created with VS will be of that encoding.

Hence you can set the encoding of each file type independently.

like image 119
Lars-Erik Avatar answered Oct 15 '22 17:10

Lars-Erik