Amazon.S3.Util.AmazonS3Uri.FromHex C# (CSharp) Method

FromHex() static private method

Converts a hex character (0-9A-Fa-f) into its corresponding quad value.
static private FromHex ( char c ) : int
c char The hex character
return int
        static int FromHex(char c)
        {
            if (c < '0')
            {
                throw new InvalidOperationException(
                    "Invalid percent-encoded string: bad character '" + c + "' in "
                    + "escape sequence.");
            }
            if (c <= '9')
            {
                return (c - '0');
            }

            if (c < 'A')
            {
                throw new InvalidOperationException(
                    "Invalid percent-encoded string: bad character '" + c + "' in "
                    + "escape sequence.");
            }
            if (c <= 'F')
            {
                return (c - 'A') + 10;
            }

            if (c < 'a')
            {
                throw new InvalidOperationException(
                    "Invalid percent-encoded string: bad character '" + c + "' in "
                    + "escape sequence.");
            }
            if (c <= 'f')
            {
                return (c - 'a') + 10;
            }

            throw new InvalidOperationException(
                "Invalid percent-encoded string: bad character '" + c + "' in "
                + "escape sequence.");
        }
    }