digitToIntOrNull

Returns the numeric value of the decimal digit that this Char represents, or null if this Char is not a valid decimal digit.

fun Char.digitToIntOrNull(): Int?(source)
fun main() {
    val chars = "a5f2"

    for (c in chars) {
        val value = c.digitToIntOrNull()
        println("Character: '$c' → ${value ?: "not a digit"}")
    }
}

Source