digitToInt -package:sbv

Convert a single digit Char to the corresponding Int. This function fails unless its argument satisfies isHexDigit, but recognises both upper- and lower-case hexadecimal digits (that is, '0'..'9', 'a'..'f', 'A'..'F').

Examples

Characters '0' through '9' are converted properly to 0..9:
>>> map digitToInt ['0'..'9']
[0,1,2,3,4,5,6,7,8,9]
Both upper- and lower-case 'A' through 'F' are converted as well, to 10..15.
>>> map digitToInt ['a'..'f']
[10,11,12,13,14,15]

>>> map digitToInt ['A'..'F']
[10,11,12,13,14,15]
Anything else throws an exception:
>>> digitToInt 'G'
*** Exception: Char.digitToInt: not a digit 'G'

>>> digitToInt '♥'
*** Exception: Char.digitToInt: not a digit '\9829'
Return the decimal digit value of a decimal digit character. Such characters have the general category Nd (decimal digit numbers) and a NumericType_ of NTDecimal. No digit values are returned for any Han characters, because Han number characters are often used with a special Chinese-style number format (with characters for powers of 10 in between) instead of in decimal-positional notation. Unicode 4 explicitly assigns Han number characters a NumericType_ of NTNumeric instead of NTDecimal.