HexFormat

Represents hexadecimal format options for formatting and parsing byte arrays and integer numeric values, both signed and unsigned.

An instance of this class is passed to formatting and parsing functions and specifies how formatting and parsing should be conducted. The options of the bytes property apply only when formatting and parsing byte arrays, while the number property applies when formatting and parsing numeric values. The upperCase option affects both.

This class is immutable and cannot be created or configured directly. To create a new format, use the HexFormat { } builder function and configure the options inside the braces. For example, use val format = HexFormat { upperCase = true } to enable upper-case formatting.

Two predefined instances are provided by this class's companion object: Default and UpperCase. The Default instance has the upperCase option set to false, and the options of bytes and number properties set to their default values as specified in BytesHexFormat and NumberHexFormat, respectively. The UpperCase instance has the upperCase option set to true, and the options of bytes and number properties set to their default values.

Since Kotlin

1.9

See also

Samples

Types

Link copied to clipboard
class Builder

Provides an API for building a HexFormat.

Since Kotlin 1.9
Link copied to clipboard

Represents hexadecimal format options for formatting and parsing byte arrays.

Since Kotlin 1.9
Link copied to clipboard
object Companion
Since Kotlin 1.9
Link copied to clipboard

Represents hexadecimal format options for formatting and parsing numeric values.

Since Kotlin 1.9

Properties

Link copied to clipboard

Specifies the hexadecimal format used for formatting and parsing byte arrays.

Since Kotlin 1.9
Link copied to clipboard

Specifies the hexadecimal format used for formatting and parsing numeric values.

Since Kotlin 1.9
Link copied to clipboard

Specifies whether upper-case hexadecimal digits should be used for formatting, false by default.

Since Kotlin 1.9

Functions

Link copied to clipboard
open override fun toString(): String
Since Kotlin 1.9