library/src/main/java/com/qiniu/android/dns/util/Hex.java
protected static int toDigit(final char ch, final int index) throws HexDecodeException {
        final int digit = Character.digit(ch, 16);
        if (digit == -1) {
            throw new HexDecodeException("Illegal hexadecimal character " + ch + " at index " + index);
        }
        return digit;
    }
protected static int toDigit(final char ch, final int index) throws HexDecodeException {
        final int digit = Character.digit(ch, 16);
        if (digit == -1) {
            throw new HexDecodeException("Illegal hexadecimal character " + ch + " at index " + index);
        }
        return digit;
    }
Converts a hexadecimal character to an integer.

@param ch    A character to convert to an integer digit
@param index The index of the character in the source
@return An integer
@throws HexDecodeException Thrown if ch is an illegal hex character