using System;
using System.Text;
using ICD.Common.Properties;
namespace ICD.Common.Utils
{
public static class EncodingUtils
{
///
/// Strips leading Byte Order Mark characters from the given UTF8 data.
///
/// Input string to remove leading BOM chars from.
/// Input string with leading BOM chars removed.
/// Data is null.
[PublicAPI]
public static string StripUtf8Bom(string data)
{
if (data == null)
throw new ArgumentNullException("data");
byte[] preamble = Encoding.UTF8.GetPreamble();
string preambleString = Encoding.UTF8.GetString(preamble, 0, preamble.Length);
if (data.StartsWith(preambleString, StringComparison.Ordinal))
data = data.Remove(0, preambleString.Length);
return data;
}
}
}