Base64Url.TryDecodeFromChars Method

Definition

Decodes the span of Unicode ASCII chars represented as Base64Url into binary data.

C#
public static bool TryDecodeFromChars(ReadOnlySpan<char> source, Span<byte> destination, out int bytesWritten);

Parameters

source
ReadOnlySpan<Char>

The input span which contains ASCII chars 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.

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.

Returns

true if bytes decoded successfully; false if destination is too small.

Exceptions

source contains an invalid Base64Url character,

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

Applies to

Product Versions
.NET 8 (package-provided), 9, 10
.NET Standard 2.0 (package-provided), 2.1 (package-provided)