String to int conversions with base argument support

minor nit: it's probably not a huge deal, but it's better to put the cheap integer comparisons first, so that it's able to skip the more-expensive string comparisons.