Upraviť

Zdieľať cez


EncodingExtensions.GetBytes Method

Definition

Overloads

GetBytes(Encoding, ReadOnlySequence<Char>)

Encodes the specified ReadOnlySequence<T> into a Byte array using the specified Encoding.

GetBytes(Encoding, ReadOnlySequence<Char>, IBufferWriter<Byte>)

Decodes the specified ReadOnlySequence<T> to bytes using the specified Encoding and writes the result to writer.

GetBytes(Encoding, ReadOnlySequence<Char>, Span<Byte>)

Encodes the specified ReadOnlySequence<T> to bytes using the specified Encoding and outputs the result to bytes.

GetBytes(Encoding, ReadOnlySpan<Char>, IBufferWriter<Byte>)

Encodes the specified ReadOnlySpan<T> to bytes using the specified Encoding and writes the result to writer.

GetBytes(Encoding, ReadOnlySequence<Char>)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Encodes the specified ReadOnlySequence<T> into a Byte array using the specified Encoding.

public:
[System::Runtime::CompilerServices::Extension]
 static cli::array <System::Byte> ^ GetBytes(System::Text::Encoding ^ encoding, System::Buffers::ReadOnlySequence<char> % chars);
public static byte[] GetBytes (this System.Text.Encoding encoding, in System.Buffers.ReadOnlySequence<char> chars);
static member GetBytes : System.Text.Encoding * ReadOnlySequence -> byte[]
<Extension()>
Public Function GetBytes (encoding As Encoding, ByRef chars As ReadOnlySequence(Of Char)) As Byte()

Parameters

encoding
Encoding

The encoding that represents how the data in chars should be encoded.

chars
ReadOnlySequence<Char>

The sequence to encode to bytes.

Returns

Byte[]

A Byte array that represents the encoded contents of chars.

Exceptions

chars contains data that cannot be encoded and encoding is configured to throw when such data is seen.

Applies to

GetBytes(Encoding, ReadOnlySequence<Char>, IBufferWriter<Byte>)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Decodes the specified ReadOnlySequence<T> to bytes using the specified Encoding and writes the result to writer.

public:
[System::Runtime::CompilerServices::Extension]
 static long GetBytes(System::Text::Encoding ^ encoding, System::Buffers::ReadOnlySequence<char> % chars, System::Buffers::IBufferWriter<System::Byte> ^ writer);
public static long GetBytes (this System.Text.Encoding encoding, in System.Buffers.ReadOnlySequence<char> chars, System.Buffers.IBufferWriter<byte> writer);
static member GetBytes : System.Text.Encoding * ReadOnlySequence * System.Buffers.IBufferWriter<byte> -> int64
<Extension()>
Public Function GetBytes (encoding As Encoding, ByRef chars As ReadOnlySequence(Of Char), writer As IBufferWriter(Of Byte)) As Long

Parameters

encoding
Encoding

The encoding that represents how the data in chars should be encoded.

chars
ReadOnlySequence<Char>

The ReadOnlySequence<T> whose contents should be encoded.

writer
IBufferWriter<Byte>

The buffer to which the encoded bytes will be written.

Returns

The number of bytes written to writer.

Exceptions

chars contains data that cannot be encoded and encoding is configured to throw when such data is seen.

Applies to

GetBytes(Encoding, ReadOnlySequence<Char>, Span<Byte>)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Encodes the specified ReadOnlySequence<T> to bytes using the specified Encoding and outputs the result to bytes.

public:
[System::Runtime::CompilerServices::Extension]
 static int GetBytes(System::Text::Encoding ^ encoding, System::Buffers::ReadOnlySequence<char> % chars, Span<System::Byte> bytes);
public static int GetBytes (this System.Text.Encoding encoding, in System.Buffers.ReadOnlySequence<char> chars, Span<byte> bytes);
static member GetBytes : System.Text.Encoding * ReadOnlySequence * Span<byte> -> int
<Extension()>
Public Function GetBytes (encoding As Encoding, ByRef chars As ReadOnlySequence(Of Char), bytes As Span(Of Byte)) As Integer

Parameters

encoding
Encoding

The encoding that represents how the data in chars should be encoded.

chars
ReadOnlySequence<Char>

The sequence to encode to bytes.

bytes
Span<Byte>

The destination buffer to which the encoded bytes will be written.

Returns

The number of bytes written to bytes.

Exceptions

bytes is not large enough to contain the encoded form of chars.

chars contains data that cannot be encoded and encoding is configured to throw when such data is seen.

Applies to

GetBytes(Encoding, ReadOnlySpan<Char>, IBufferWriter<Byte>)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Encodes the specified ReadOnlySpan<T> to bytes using the specified Encoding and writes the result to writer.

public:
[System::Runtime::CompilerServices::Extension]
 static long GetBytes(System::Text::Encoding ^ encoding, ReadOnlySpan<char> chars, System::Buffers::IBufferWriter<System::Byte> ^ writer);
public static long GetBytes (this System.Text.Encoding encoding, ReadOnlySpan<char> chars, System.Buffers.IBufferWriter<byte> writer);
static member GetBytes : System.Text.Encoding * ReadOnlySpan<char> * System.Buffers.IBufferWriter<byte> -> int64
<Extension()>
Public Function GetBytes (encoding As Encoding, chars As ReadOnlySpan(Of Char), writer As IBufferWriter(Of Byte)) As Long

Parameters

encoding
Encoding

The encoding that represents how the data in chars should be encoded.

chars
ReadOnlySpan<Char>

The sequence to encode to bytes.

writer
IBufferWriter<Byte>

The buffer to which the encoded bytes will be written.

Returns

The number of bytes written to writer.

Exceptions

chars contains data that cannot be encoded and encoding is configured to throw when such data is seen.

Applies to