Edit

Share via


Base64Url.DecodeFromUtf8InPlace(Span<Byte>) Method

Definition

Decodes the span of UTF-8 encoded text in Base64Url into binary data, in-place.

The decoded binary output is smaller than the text data contained in the input (the operation deflates the data).

public:
 static int DecodeFromUtf8InPlace(Span<System::Byte> buffer);
public static int DecodeFromUtf8InPlace (Span<byte> buffer);
static member DecodeFromUtf8InPlace : Span<byte> -> int
Public Shared Function DecodeFromUtf8InPlace (buffer As Span(Of Byte)) As Integer

Parameters

buffer
Span<Byte>

The input span which contains the base 64 text data that needs to be decoded.

Returns

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

Exceptions

buffer 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 buffer length not required to be a multiple of 4.

If the buffer 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