Skip to content

Commit

Permalink
Merge pull request #5 from execute233/main
Browse files Browse the repository at this point in the history
fixed: ConvertFromUtf16BEBytesToUtf8BOMBytes()
  • Loading branch information
lc6464 committed Oct 1, 2023
2 parents 21a3f39 + 5714efb commit 3845ade
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public static ReadOnlySpan<byte> ConvertFromUtf16BEBytesToUtf8Bytes(this ReadOnl
/// <param name="data">UTF-16 BE 编码的数据</param>
/// <returns>UTF-8 with BOM 编码的数据</returns>
public static ReadOnlySpan<byte> ConvertFromUtf16BEBytesToUtf8BOMBytes(this ReadOnlySpan<byte> data) {
Span<byte> buffer = new byte[data.Length + 3];
var utf8Bytes = data.ConvertFromUtf16BEBytesToUtf8Bytes();
Span<byte> buffer = new byte[utf8Bytes.Length + 3];
Utf8Preamble.CopyTo(buffer);
data.ConvertFromUtf16BEBytesToUtf8Bytes().CopyTo(buffer[3..]);
utf8Bytes.CopyTo(buffer[3..]);
return buffer;
}

Expand Down

0 comments on commit 3845ade

Please sign in to comment.