int (String s, int offset, int radix) { int sum = 0; int i = offset; for (; i < s.length(); i++) { final int digit = Character.digit(s.charAt(i), radix); if (digit < 0) { // '}' encountered break; } sum = sum * radix + digit; if (sum > Character.MAX_CODE_POINT) { return -1; } }