Base64.EncodeToUtf8 Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Encodes the span of binary data into UTF-8 encoded text represented as base 64.
public static System.Buffers.OperationStatus EncodeToUtf8 (ReadOnlySpan<byte> bytes, Span<byte> utf8, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true);
static member EncodeToUtf8 : ReadOnlySpan<byte> * Span<byte> * int * int * bool -> System.Buffers.OperationStatus
Public Shared Function EncodeToUtf8 (bytes As ReadOnlySpan(Of Byte), utf8 As Span(Of Byte), ByRef bytesConsumed As Integer, ByRef bytesWritten As Integer, Optional isFinalBlock As Boolean = true) As OperationStatus
Parameters
- bytes
- ReadOnlySpan<Byte>
The input span that contains binary data that needs to be encoded.
The output span that contains the result of the operation, that is, the UTF-8 encoded text in base 64.
- bytesConsumed
- Int32
When this method returns, contains the number of input bytes consumed during the operation. This can be used to slice the input for subsequent calls, if necessary.
- bytesWritten
- Int32
When this method returns, contains the number of bytes written into the output span. This can be used to slice the output for subsequent calls, if necessary.
- isFinalBlock
- Boolean
true
(the default) to indicate that the input span contains the entire data to encode. false
to indicate that the input span contains partial data with more data to follow.
Returns
One of the enumeration values that indicates the status of the encoding operation.
Remarks
The return value can be as follows:
- OperationStatus.Done: Processing of the entire input span succeeded.
- OperationStatus.DestinationTooSmall: There isn't enough space in the output span to fit the encoded input.
- OperationStatus.NeedMoreData:
isFinalBlock
isfalse
. Otherwise, ifisFinalBlock
istrue
, the output is padded if the input is not a multiple of 3.
This method cannot return OperationStatus.InvalidData since that is not possible for base-64 encoding.