コード例 #1
0
 /// <summary>
 /// Encodes input strings for use in universal resource locators (URLs).
 /// </summary>
 /// <param name="input">String to be encoded.</param>
 /// <param name="codePage">Codepage number of the input.</param>
 /// <returns>
 /// Encoded string for use in URLs.
 /// </returns>
 /// <remarks>
 /// This function encodes the output as per the encoding parameter (codepage) passed to it. It encodes
 /// all but known safe characters.  Characters are encoded using %SINGLE_BYTE_HEX and %DOUBLE_BYTE_HEX notation.
 /// <newpara />
 /// Safe characters include:
 /// <list type="table">
 /// <item><term>a-z</term><description>Lower case alphabet</description></item>
 /// <item><term>A-Z</term><description>Upper case alphabet</description></item>
 /// <item><term>0-9</term><description>Numbers</description></item>
 /// <item><term>.</term><description>Period</description></item>
 /// <item><term>-</term><description>Dash</description></item>
 /// <item><term>_</term><description>Underscore</description></item>
 /// <item><term>~</term><description>Tilde</description></item>
 /// </list>
 /// <newpara />
 /// Example inputs and encoded outputs:
 /// <list type="table">
 /// <item><term>alert('XSSあAttack!');</term><description>alert%28%27XSS%82%a0Attack%21%27%29%3b</description></item>
 /// <item><term>[email protected]</term><description>user%40contoso.com</description></item>
 /// <item><term>Anti-Cross Site Scripting Library</term><description>Anti-Cross%20Site%20Scripting%20Library</description></item>
 /// </list>
 /// </remarks>
 public static string UrlEncode(string input, int codePage)
 {
     return(Encoder.UrlEncode(input, Encoding.GetEncoding(codePage)));
 }
コード例 #2
0
 /// <summary>
 /// Encodes input strings for use in universal resource locators (URLs).
 /// </summary>
 /// <param name="input">String to be encoded.</param>
 /// <returns>
 /// Encoded string for use in URLs.
 /// </returns>
 /// <remarks>
 /// This function encodes all but known safe characters.  Characters are encoded using %SINGLE_BYTE_HEX
 /// and %DOUBLE_BYTE_HEX notation.
 /// <newpara />
 /// Safe characters include:
 /// <list type="table">
 /// <item><term>a-z</term><description>Lower case alphabet</description></item>
 /// <item><term>A-Z</term><description>Upper case alphabet</description></item>
 /// <item><term>0-9</term><description>Numbers</description></item>
 /// <item><term>.</term><description>Period</description></item>
 /// <item><term>-</term><description>Dash</description></item>
 /// <item><term>_</term><description>Underscore</description></item>
 /// <item><term>~</term><description>Tilde</description></item>
 /// </list>
 /// <newpara />
 /// Example inputs and encoded outputs:
 /// <list type="table">
 /// <item><term>alert('XSS Attack!');</term><description>alert%28%27XSS%20Attack%21%27%29%3b</description></item>
 /// <item><term>[email protected]</term><description>user%40contoso.com</description></item>
 /// <item><term>Anti-Cross Site Scripting Library</term><description>Anti-Cross%20Site%20Scripting%20Library</description></item>
 /// </list>
 /// </remarks>
 public static string UrlEncode(string input)
 {
     return(Encoder.UrlEncode(input, Encoding.UTF8));
 }