Reverted all changes in 'System.Text/Encoding.cs' and disabled the emitIdentifier...
authorGerardo García Peña <killabytenow@gmail.com>
Thu, 23 May 2013 13:43:27 +0000 (15:43 +0200)
committerGerardo García Peña <killabytenow@gmail.com>
Thu, 23 May 2013 13:43:27 +0000 (15:43 +0200)
mcs/class/corlib/System.Text/Encoding.cs
mcs/class/corlib/System.Text/UTF8Encoding.cs

index 944a14014984b137ed3fb23b3caf0493be6e7726..4903ec5cf379d4fd8d5cf59a0ea5f23ac7f4d646 100644 (file)
@@ -797,6 +797,7 @@ public abstract class Encoding : ICloneable
        static volatile Encoding bigEndianEncoding;
        static volatile Encoding defaultEncoding;
        static volatile Encoding utf7Encoding;
+       static volatile Encoding utf8EncodingWithMarkers;
        static volatile Encoding utf8EncodingWithoutMarkers;
        static volatile Encoding unicodeEncoding;
        static volatile Encoding isoLatin1Encoding;
@@ -936,7 +937,23 @@ public abstract class Encoding : ICloneable
        public static Encoding UTF8
        {
                get {
-                       return UTF8Unmarked;
+                       if (utf8EncodingWithMarkers == null) {
+                               lock (lockobj) {
+                                       if (utf8EncodingWithMarkers == null) {
+                                               // 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 (true);
+//                                             utf8EncodingWithMarkers.is_readonly = true;
+                                       }
+                               }
+                       }
+
+                       return utf8EncodingWithMarkers;
                }
        }
 
index df5bdc6bec76f551067facd56e942b34f0015577..d401c88b0d2ecfede459b58f5a787517348f579a 100644 (file)
@@ -1101,7 +1101,7 @@ again:
                {
                        this.Fallback = fallback;
                        this.leftChar = 0;
-                       this.emitIdentifier = emitIdentifier;
+                       this.emitIdentifier = false; //emitIdentifier;
                        this.emittedIdentifier = false;
                }