decimalValue function

int decimalValue(
  1. int codeUnit
)

The value of a single decimal character, 0-9. Anything else yields -1, so a number assembled from junk fails validation downstream rather than throwing here.

Sits in shared/ rather than shared/check_digits/ because it is not check-digit-specific: every algorithm there decodes with it, and so does Digits.

Implementation

int decimalValue(int codeUnit) =>
    codeUnit >= _asciiZero && codeUnit <= _asciiNine ? codeUnit - _asciiZero : -1;