-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BOM was hot handled correctly everywhere
- Loading branch information
Showing
5 changed files
with
36 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Xml; | ||
|
||
namespace Bannerlord.LauncherManager.Native; | ||
|
||
public static class ReaderUtils2 | ||
{ | ||
private static readonly byte[] BOMMarkUtf8 = Encoding.UTF8.GetPreamble(); | ||
|
||
public static XmlDocument Read(ReadOnlySpan<char> xml) | ||
{ | ||
var doc = new XmlDocument(); | ||
doc.LoadXml(new string(RemoveBOM2(xml))); | ||
return doc; | ||
} | ||
|
||
private static ReadOnlySpan<char> RemoveBOM2(ReadOnlySpan<char> xml) | ||
{ | ||
var bom = MemoryMarshal.Cast<byte, char>(BOMMarkUtf8.AsSpan()); | ||
if (xml.StartsWith(bom)) | ||
xml = xml.Slice(bom.Length); | ||
return xml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters