Class Hex
Provides conversion to/from hexadecimal representation.
Inherited Members
Namespace: DotNext.Buffers.Text
Assembly: DotNext.dll
Syntax
public static class Hex
Methods
| Edit this page View SourceDecodeFromUtf16(ReadOnlySpan<char>, Span<byte>)
Decodes hexadecimal representation of bytes.
Declaration
public static int DecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> output)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | chars | The hexadecimal representation of bytes. |
Span<byte> | output | The output buffer used to write decoded bytes. |
Returns
Type | Description |
---|---|
int | The actual number of bytes in |
Exceptions
Type | Condition |
---|---|
FormatException |
|
DecodeFromUtf8(ReadOnlySpan<byte>, Span<byte>)
Decodes hexadecimal representation of bytes.
Declaration
public static int DecodeFromUtf8(ReadOnlySpan<byte> chars, Span<byte> output)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | chars | The hexadecimal representation of bytes. |
Span<byte> | output | The output buffer used to write decoded bytes. |
Returns
Type | Description |
---|---|
int | The actual number of bytes in |
Exceptions
Type | Condition |
---|---|
FormatException |
|
EncodeToUtf16(ReadOnlySpan<byte>, bool)
Converts set of bytes into hexadecimal representation.
Declaration
public static string EncodeToUtf16(ReadOnlySpan<byte> bytes, bool lowercased = false)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | bytes | The bytes to convert. |
bool | lowercased | true to return lowercased hex string; false to return uppercased hex string. |
Returns
Type | Description |
---|---|
string | The hexadecimal representation of bytes. |
EncodeToUtf16(ReadOnlySpan<byte>, Span<char>, bool)
Converts set of bytes into hexadecimal representation.
Declaration
public static int EncodeToUtf16(ReadOnlySpan<byte> bytes, Span<char> output, bool lowercased = false)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | bytes | The bytes to convert. |
Span<char> | output | The buffer used to write hexadecimal representation of bytes. |
bool | lowercased | true to return lowercased hex string; false to return uppercased hex string. |
Returns
Type | Description |
---|---|
int | The actual number of characters in |
EncodeToUtf8(ReadOnlySpan<byte>, bool)
Converts set of bytes into hexadecimal representation.
Declaration
public static byte[] EncodeToUtf8(ReadOnlySpan<byte> bytes, bool lowercased = false)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | bytes | The bytes to convert. |
bool | lowercased | true to return lowercased hex string; false to return uppercased hex string. |
Returns
Type | Description |
---|---|
byte[] | The hexadecimal representation of bytes. |
EncodeToUtf8(ReadOnlySpan<byte>, Span<byte>, bool)
Converts set of bytes into hexadecimal representation.
Declaration
public static int EncodeToUtf8(ReadOnlySpan<byte> bytes, Span<byte> output, bool lowercased = false)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | bytes | The bytes to convert. |
Span<byte> | output | The buffer used to write hexadecimal representation of bytes, in UTF-8 encoding. |
bool | lowercased | true to return lowercased hex string; false to return uppercased hex string. |
Returns
Type | Description |
---|---|
int | The actual number of characters in |