Edit

Share via


Base64Url.DecodeFromUtf8 Method

Definition

Overloads

DecodeFromUtf8(ReadOnlySpan<Byte>)

Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.

DecodeFromUtf8(ReadOnlySpan<Byte>, Span<Byte>)

Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.

DecodeFromUtf8(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Boolean)

Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.

DecodeFromUtf8(ReadOnlySpan<Byte>)

Source:
Base64UrlDecoder.cs

Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.

public:
 static cli::array <System::Byte> ^ DecodeFromUtf8(ReadOnlySpan<System::Byte> source);
public static byte[] DecodeFromUtf8 (ReadOnlySpan<byte> source);
static member DecodeFromUtf8 : ReadOnlySpan<byte> -> byte[]
Public Shared Function DecodeFromUtf8 (source As ReadOnlySpan(Of Byte)) As Byte()

Parameters

source
ReadOnlySpan<Byte>

The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.

Returns

Byte[]

>A byte array which contains the result of the decoding operation.

Exceptions

source contains an invalid Base64Url character,

more than two padding characters, or a non white space character among the padding characters.

Applies to

DecodeFromUtf8(ReadOnlySpan<Byte>, Span<Byte>)

Source:
Base64UrlDecoder.cs

Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.

public:
 static int DecodeFromUtf8(ReadOnlySpan<System::Byte> source, Span<System::Byte> destination);
public static int DecodeFromUtf8 (ReadOnlySpan<byte> source, Span<byte> destination);
static member DecodeFromUtf8 : ReadOnlySpan<byte> * Span<byte> -> int
Public Shared Function DecodeFromUtf8 (source As ReadOnlySpan(Of Byte), destination As Span(Of Byte)) As Integer

Parameters

source
ReadOnlySpan<Byte>

The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.

destination
Span<Byte>

The output span which contains the result of the operation, i.e. the decoded binary data.

Returns

The number of bytes written into destination. This can be used to slice the output for subsequent calls, if necessary.

Exceptions

The buffer in destination is too small to hold the encoded output.

source contains an invalid Base64Url character,

more than two padding characters, or a non white space character among the padding characters.

Remarks

As padding is optional for Base64Url the source length not required to be a multiple of 4.

If the source length is not a multiple of 4 the remainders decoded accordingly:

- Remainder of 3 bytes - decoded into 2 bytes data, decoding succeeds.

- Remainder of 2 bytes - decoded into 1 byte data. decoding succeeds.

- Remainder of 1 byte - is invalid input, causes FormatException.

Applies to

DecodeFromUtf8(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Boolean)

Source:
Base64UrlDecoder.cs

Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.

public static System.Buffers.OperationStatus DecodeFromUtf8 (ReadOnlySpan<byte> source, Span<byte> destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true);
static member DecodeFromUtf8 : ReadOnlySpan<byte> * Span<byte> * int * int * bool -> System.Buffers.OperationStatus
Public Shared Function DecodeFromUtf8 (source As ReadOnlySpan(Of Byte), destination As Span(Of Byte), ByRef bytesConsumed As Integer, ByRef bytesWritten As Integer, Optional isFinalBlock As Boolean = true) As OperationStatus

Parameters

source
ReadOnlySpan<Byte>

The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.

destination
Span<Byte>

The output span which contains the result of the operation, i.e. the decoded binary data.

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. This parameter is treated as uninitialized.

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. This parameter is treated as uninitialized.

isFinalBlock
Boolean

true when the input span contains the entirety of data to encode; false when more data may follow,

such as when calling in a loop. Calls with false should be followed up with another call where this parameter is true call. The default is true.

Returns

One of the enumeration values that indicates the success or failure of the operation.

Remarks

As padding is optional for Base64Url the source length not required to be a multiple of 4 even if isFinalBlock is true.

If the source length is not a multiple of 4 and isFinalBlock is true the remainders decoded accordingly:

- Remainder of 3 bytes - decoded into 2 bytes data, decoding succeeds.

- Remainder of 2 bytes - decoded into 1 byte data. decoding succeeds.

- Remainder of 1 byte - will cause OperationStatus.InvalidData result.

Applies to