mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 12:37:13 +00:00
feat: Added util method for removing BOM characters from UTF8 data
This commit is contained in:
parent
e446f6e6ce
commit
110f771cc5
4 changed files with 55 additions and 0 deletions
23
ICD.Common.Utils.Tests/EncodingUtilsTest.cs
Normal file
23
ICD.Common.Utils.Tests/EncodingUtilsTest.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ICD.Common.Utils.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class EncodingUtilsTest
|
||||
{
|
||||
[Test]
|
||||
public void StripUtf8BomTest()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => EncodingUtils.StripUtf8Bom(null));
|
||||
|
||||
byte[] preamble = Encoding.UTF8.GetPreamble();
|
||||
string preambleString = Encoding.UTF8.GetString(preamble, 0, preamble.Length);
|
||||
|
||||
Assert.AreEqual(string.Empty, EncodingUtils.StripUtf8Bom(string.Empty));
|
||||
Assert.AreEqual("test", EncodingUtils.StripUtf8Bom("test"));
|
||||
Assert.AreEqual("test", EncodingUtils.StripUtf8Bom(preambleString + "test"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue