Disable BOM preamble in UTF8 by default (following best practices).
authorGerardo García Peña <killabytenow@gmail.com>
Mon, 29 Apr 2013 06:09:23 +0000 (08:09 +0200)
committerGerardo García Peña <killabytenow@gmail.com>
Mon, 29 Apr 2013 06:09:23 +0000 (08:09 +0200)
mcs/class/corlib/System.Text/Encoding.cs

index 6bdfa5461123832db291d81731942067f5456df1..97c2e5289aa36c07b8b85b37830c4b25964f6808 100644 (file)
@@ -940,7 +940,14 @@ public abstract class Encoding : ICloneable
                        if (utf8EncodingWithMarkers == null) {
                                lock (lockobj) {
                                        if (utf8EncodingWithMarkers == null) {
-                                               utf8EncodingWithMarkers = new UTF8Encoding (true);
+                                               // MS.NET does not enable BOM
+                                               // preamble by default
+                                               // NOTE: In fact is a bad idea
+                                               // to add an UTF8 BOM because
+                                               // it breaks compatibility with
+                                               // ASCII (i.e. shell scripts):
+                                               // http://www.unicode.org/faq/utf_bom.html#bom5
+                                               utf8EncodingWithMarkers = new UTF8Encoding (false);
 //                                             utf8EncodingWithMarkers.is_readonly = true;
                                        }
                                }