コード例 #1
0
        /// <summary>
        /// Percent encodes entities as per https://tools.ietf.org/html/rfc3986.
        /// </summary>
        internal static string ToUriRfc3986(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return(input);
            }

            var escaped = new StringBuilder(Uri.EscapeDataString(input));

            string[] uriRfc3986EscapedChars = { "!", "*", "'", "(", ")" };
            foreach (var escapedChar in uriRfc3986EscapedChars)
            {
                escaped.Replace(escapedChar, UriUtils.HexEscape(escapedChar[0]));
            }
            return(escaped.ToString());
        }