EncodeUri() public static method

public static EncodeUri ( string uriToEncode, string charset ) : string
uriToEncode string
charset string
return string
        /// <summary>
        /// Applies the Url encoding on the key
        /// </summary>
        /// <param name="key">the object key to encode</param>
        /// <returns>The encoded key</returns>
        private static String UrlEncodeKey(String key)
        {
            const char separator = '/';
            var        segments  = key.Split(separator);

            var encodedKey = new StringBuilder();

            encodedKey.Append(HttpUtils.EncodeUri(segments[0], CharsetName));
            for (var i = 1; i < segments.Length; i++)
            {
                encodedKey.Append(separator).Append(HttpUtils.EncodeUri(segments[i], CharsetName));
            }

            if (key.EndsWith(separator.ToString()))
            {
                // String#split ignores trailing empty strings, e.g., "a/b/" will be split as a 2-entries array,
                // so we have to append all the trailing slash to the uri.
                foreach (var ch in key)
                {
                    if (ch == separator)
                    {
                        encodedKey.Append(separator);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(encodedKey.ToString());
        }