Save UTF-8 without BOM Visual Studio 2012

9

1

It seems that Visual Studio 2012 hates UTF-8 without BOM and always adds it, resulting in an empty line in PHP pages.

How can I change the encoding to UTF-8 without BOM (or at least to Unicode...)

Cristy

Posted 2013-01-16T20:36:58.280

Reputation: 331

Please add some more info about what you are doing. – harrymc – 2013-02-05T16:23:14.083

I can not save documents with UTF-8 without BOM encoding using Visual Studio 2012. I have to edit the file in Notepad++ every time to change to that encoding. – Cristy – 2013-02-05T18:20:33.017

Answers

9

See the free Fix File Encoding extension :

The free Fix File Encoding extension prevents Visual Studio 2012/2010 from adding BOM to UTF-8 files.

Normally, when you edit a UTF-8 file in Visual Studio, it adds the byte order mark (BOM) sequence 0xEF, 0xBB, 0xBF to the beginning of the file. Sometimes it confuses other applications further processing the file. You can select an encoding manually (File - Advanced Save Options... or File - Save As... - Save with Encoding...), but you need to do it each time you reopen the file:

Fix File Encoding automatically detects when a UTF-8 file is opened in Visual Studio and sets its encoding to UTF-8 without signature. If you don't edit the file, it remains unmodified. If you edit the file, it will be saved without the BOM.

Fix File Encoding lets you configure which files to encode based on the file path and the file extension. By default, only .html files are protected from Visual Studio.

I have no experience with this extension, but it sounds like it answers your needs.

harrymc

Posted 2013-01-16T20:36:58.280

Reputation: 306 093