Base64Url.EncodeToUtf8 Method
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.
EncodeToUtf8(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Boolean) |
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url. |
EncodeToUtf8(ReadOnlySpan<Byte>, Span<Byte>) |
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url. |
EncodeToUtf8(ReadOnlySpan<Byte>) |
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url. |
- Source:
- Base64UrlEncoder.cs
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
public static System.Buffers.OperationStatus EncodeToUtf8 (ReadOnlySpan<byte> source, Span<byte> destination, 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 (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 binary data that needs to be encoded.
The output span which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.
- 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, subsequent calls with false
should end with true
call. The default is true
.
Returns
One of the enumeration values that indicates the success or failure of the operation.
Remarks
This implementation of the base64url encoding omits the optional padding characters.
Applies to
.NET 9 and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
- Source:
- Base64UrlEncoder.cs
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
public:
static int EncodeToUtf8(ReadOnlySpan<System::Byte> source, Span<System::Byte> destination);
public static int EncodeToUtf8 (ReadOnlySpan<byte> source, Span<byte> destination);
static member EncodeToUtf8 : ReadOnlySpan<byte> * Span<byte> -> int
Public Shared Function EncodeToUtf8 (source As ReadOnlySpan(Of Byte), destination As Span(Of Byte)) As Integer
Parameters
- source
- ReadOnlySpan<Byte>
The input span which contains binary data that needs to be encoded.
The output span which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.
Returns
The number of bytes written into the destination span. 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.
Remarks
This implementation of the base64url encoding omits the optional padding characters.
Applies to
.NET 9 and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
- Source:
- Base64UrlEncoder.cs
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
public:
static cli::array <System::Byte> ^ EncodeToUtf8(ReadOnlySpan<System::Byte> source);
public static byte[] EncodeToUtf8 (ReadOnlySpan<byte> source);
static member EncodeToUtf8 : ReadOnlySpan<byte> -> byte[]
Public Shared Function EncodeToUtf8 (source As ReadOnlySpan(Of Byte)) As Byte()
Parameters
- source
- ReadOnlySpan<Byte>
The input span which contains binary data that needs to be encoded.
Returns
The output byte array which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.
Remarks
This implementation of the base64url encoding omits the optional padding characters.
Applies to
.NET 9 and other versions
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: