Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Visual Studio (2008 and 2010) put three bytes at the beginning of text and XML files that it creates?

When I use Visual Studio (2008 and 2010) to create a new text or XML file, it always includes three strange-looking bytes at the very beginning of the file. These three bytes can't be seen unless you are using a binary editor.

3 Bytes in text file

Why are they there and what do they do?

Is there a way to stop Visual Studio from putting them there?

As it stands I cannot use Visual Studio to create XML files because these bytes screw up the parser.

like image 310
carny666 Avatar asked Aug 31 '25 22:08

carny666


2 Answers

it's BOM or Byte Order Mark this usually happens when you save your file using other encoding especially in UTF-8 to solve it...

open File menu > select Advanced Save Options > then select UTF-8 without signature

like image 149
Netorica Avatar answered Sep 05 '25 04:09

Netorica


This is a utf8 byte order mark

see here for more information. It basically states that its a text file in utf8 format. Most text editors recognise it and therefore know how to understand the format of the file.

Is your XML parser hand rolled? All production grade XML parsers I've used have no problem (infact are positively helped) by having a correct BOM.

like image 29
Mike Vine Avatar answered Sep 05 '25 03:09

Mike Vine