Instance Propertyswift 6.0.3Swift

hexDigitValue

The numeric value this character represents, if it is a hexadecimal digit.

var hexDigitValue: Int? { get }

Hexadecimal digits include 0-9, Latin letters a-f and A-F, and their fullwidth compatibility forms. If the character does not represent a hexadecimal digit, the value of this property is nil.

let chars: [Character] = ["1", "a", "F", "g"]
for ch in chars {
    print(ch, "-->", ch.hexDigitValue)
}
// Prints:
// 1 --> Optional(1)
// a --> Optional(10)
// F --> Optional(15)
// g --> nil