Add Encoding.GetBytes polyfill to simplify D3DCompiler
このコミットが含まれているのは:
1 親
963ec0ecb4
コミット
ef821be2b2
2ファイル変更
+28
-13
検索条件に一致するファイルはありません
@@ -0,0 +1,23 @@
|
||||
namespace System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Extensions for the <see cref="Encoding"/> type.
|
||||
/// </summary>
|
||||
internal static class EncodingExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Encodes into a span of bytes a set of characters from the specified read-only span.
|
||||
/// </summary>
|
||||
/// <param name="encoding">The input <see cref="Encoding"/> instance to use.</param>
|
||||
/// <param name="chars">The span containing the set of characters to encode.</param>
|
||||
/// <param name="bytes">The byte span to hold the encoded bytes.</param>
|
||||
/// <returns>The number of encoded bytes.</returns>
|
||||
public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan<char> chars, Span<byte> bytes)
|
||||
{
|
||||
fixed (char* charsPtr = chars)
|
||||
fixed (byte* bytesPtr = bytes)
|
||||
{
|
||||
return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする