code: public static int parseNumber(String text, int[] pos, int radix) {
          // assert(pos[0] >= 0);
          // assert(radix >= 2);
          // assert(radix <= 36);
          int n = 0;
          int p = pos[0];
          while (p < text.length()) {
              int ch = Character.codePointAt(text, p);
              int d = UCharacter.digit(ch, radix);
              if (d < 0) {
                  break;
              }
              n = radix*n + d;
              // ASSUME that when a 32-bit integer overflows it becomes
              // negative.  E.g., 214748364 * 10 + 8 => negative value.
              if (n < 0) {
                  return -1;
              }
              ++p;
          }
          if (p == pos[0]) {
              return -1;
          }
          pos[0] = p;
          return n;
      }
docs: Parse an unsigned 31-bit integer at the given offset.  Use
  UCharacter.digit() to parse individual characters into digits.
  @param text the text to be parsed
  @param pos INPUT-OUTPUT parameter.  On entry, pos[0] is the
  offset within text at which to start parsing; it should point
  to a valid digit.  On exit, pos[0] is the offset after the last
  parsed character.  If the parse failed, it will be unchanged on
  exit.  Must be >= 0 on entry.
  @param radix the radix in which to parse; must be >= 2 and <=
  36.
  @return a non-negative parsed number, or -1 upon parse failure.
  Parse fails if there are no digits, that is, if pos[0] does not
  point to a valid digit on entry, or if the number to be parsed
  does not fit into a 31-bit unsigned integer.