This question is language agnostic but is inspired by these c/c++ questions.
How to convert a single char into an int
Char to int conversion in C
Is
According to K&R ANSI C it is.
Excerpt:
..."This particular program relies on the properties of the character representation of the digits. For example, the test
if (c >= '0' && c <= '9') ...determines whether the character in
cis a digit. If it is, the numeric value of that digit is
c - '0'This works only if
'0', '1', ..., '9'have consecutive increasing values. Fortunately, this is true for all character sets...."