Friday 20 April 2012

PROBLEM WITH BYTE ORDER MARK ( BOM ) CHARACTERS

I had this issue today where funny characters ( ï»¿) were always added to my JavaScript source files. After some research I found out the these are BOM (byte order mark) characters which are used to specify the byte order of a text file or stream, this is actually optional and mostly advised for UTF-16 and UTF-32 character encodings, but is discouraged for UTF-8 files.

This Wikipedia document gives in-depth explanation
http://en.wikipedia.org/wiki/Byte_order_mark

Visual studio by default saves JavaScript files with "Unicode (UTF-8 with signature) - Codepage 65001" encoding , this encoding adds the UTF-8 byte order mark at the beginning of the file. IE9 and Chrome do not have a problem with it but Firefox, Opera and Safari completely break, so to fix it

follow  the solution in this link http://forums.silverlight.net/t/144306.aspx and select the encoding option "Unicode ( UTF-8 without signature) - Codepage 65001".

Hope this helps.