Show / Hide Table of Contents

Class Hex

Provides conversion to/from hexadecimal representation.

Inheritance
object
Hex
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Buffers.Text
Assembly: DotNext.dll
Syntax
public static class Hex

Methods

| Edit this page View Source

DecodeFromUtf16(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 output written by the method.

Exceptions
Type Condition
FormatException

chars contain invalid hexadecimal symbol.

| Edit this page View Source

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 output written by the method.

Exceptions
Type Condition
FormatException

chars contain invalid hexadecimal symbol.

| Edit this page View Source

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.

| Edit this page View Source

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 output written by the method.

| Edit this page View Source

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.

| Edit this page View Source

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 output written by the method.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾