A character literal is converted with toInt() or a similar deprecated function, which gives its code, not its digit

tx0/kotlin:char-literal-to-numberrecommendedwarningreliability/strings-and-regexdepth fastbug

What it finds

'7'.toInt() is 55, the character's code, not 7. The conversion functions of Char are deprecated for that reason: code gives the code and digitToInt() the digit.

From the rule's source, char_to_code.rs.

Example from the rule's tests
fun digits(c: Char): Int {    val seven = '7'.toInt()tx0 reports: toInt() gives the code of '7', not a digit    val big = 'a'.toLong()tx0 reports: toLong() gives the code of 'a'    return seven + c.code + "7".toInt()}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:char-literal-to-number" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:char-literal-to-number] reason="..."

tx0 explain tx0/kotlin:char-literal-to-number shows the same in the terminal. Found a false positive? Report it.