From 884d603cac6c3fe0cdbd199e13e1514146ff82bc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Jul 2012 01:03:28 +0100 Subject: Rather than instantiating a UTF8 encoding everywhere when we want to supress the BOM, use a single Util.UTF8NoBomEncoding. This class is thread-safe (as evidenced by the provision of the system-wide Encoding.UTF8 which does not suppress BOM on output). --- OpenSim/Framework/Serialization/TarArchiveWriter.cs | 4 +--- OpenSim/Framework/Util.cs | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs index 122fa8e..2a3bc48 100644 --- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs +++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs @@ -41,8 +41,6 @@ namespace OpenSim.Framework.Serialization { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); - /// /// Binary writer for the underlying stream /// @@ -73,7 +71,7 @@ namespace OpenSim.Framework.Serialization /// public void WriteFile(string filePath, string data) { - WriteFile(filePath, m_utf8Encoding.GetBytes(data)); + WriteFile(filePath, Util.UTF8NoBomEncoding.GetBytes(data)); } /// diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index fd9586c..8cc29ee 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -148,6 +148,7 @@ namespace OpenSim.Framework } public static Encoding UTF8 = Encoding.UTF8; + public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false); /// /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) -- cgit v1.1