URL编码

    /// <summary>
    /// URL编码
    /// </summary>
    /// <param name="value">The value to Url encode</param>
    /// <returns>Returns a Url encoded string</returns>
    public string UrlEncode(string value)
    {
        StringBuilder result = new StringBuilder();

        string unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
        foreach (char symbol in value)
        {
            if (unreservedChars.IndexOf(symbol) != -1)
            {
                result.Append(symbol);
            }
            else
            {
                result.Append('%' + String.Format("{0:X2}", (int)symbol));
            }
        }

        return result.ToString();
    }

 

上一篇:擂台PK赛来袭,队长竟然把队员推出去送死,这究竟是道德的沦丧,还是人性的扭曲?


下一篇:10.symbol