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

AppendDecoded() static private method

Decodes the percent-encoded character at the given index in the string and appends the decoded value to the string under construction.
static private AppendDecoded ( StringBuilder builder, string s, int index ) : void
builder StringBuilder /// The string under construction to which the decoded character will be /// appended. ///
s string The string being decoded.
index int The index of the '%' character in the string.
return void
        static void AppendDecoded(StringBuilder builder, string s, int index)
        {
            if (index > s.Length - 3)
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, 
                                                                  "Invalid percent-encoded string '{0}'", 
                                                                  s));

            var first = s[index + 1];
            var second = s[index + 2];

            var decoded = (char) (FromHex(first) << 4 | FromHex(second));
            builder.Append(decoded);
        }