On Wednesday, 1 January 2014 at 20:01:56 UTC, Caeadas wrote:
Thanks much for the help, both of you :). I thought there might be a very simple way to do this, since it's so intuitive to change '4' to 4.
There have been talks about it, but it hasn't been implemented yet. The idea was to provide the function for ascii *once* we've implemented it in unicode.
I've basically just been subtracting 48 from everything, but I suppose aesthetically it's a bit nicer to convert from string instead.
Don't substract 48. That's just a number! Substract '0' :) int charToInt(char c) { c -= '0'; return c <= 9 ? c : -1; }