public static int digit(int b, int radix) {
    int r = -1;
    if (b >= '0' && b <= '9') {
      r = b - '0';
    } else if (b >= 'A' && b <= 'Z') {
      r = b - 'A' + 10;
    } else if (b >= 'a' && b <= 'z') {
      r = b - 'a' + 10;
    }
    if (r >= radix) {
      r = -1;
    }
    return r;
  }
Returns the digit represented by character b.

@param b
         The ascii code of the character
@param radix
         The radix
@return -1 if it's invalid
serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java