hexToUByte

Parses an UByte value from this string using the specified format.

inline fun String.hexToUByte(format: HexFormat = HexFormat.Default): UByte(source)
import kotlin.text.HexFormat

fun main() {
    val hexString = "FF"          // hexadecimal representation of 255
    val value: UByte = hexString.hexToUByte()   // parse to UByte
    println("Hex '$hexString' as UByte = $value") // prints: Hex 'FF' as UByte = 255
}

Source