• C# HtmlDecode、HtmlEncode、UrlEncode、UrlDecode


    不用System.Web 对 Content进行编码,De编码


    string content = "<br/>";
    string s1 = WebUtility.HtmlEncode(content);

    string s3 = WebUtility.HtmlDecode(s1);

    string s4 = WebUtility.UrlEncode(content);

    using System.IO;

    namespace System.Net
    {
    //
    // 摘要:
    // Provides methods for encoding and decoding URLs when processing Web requests.
    public static class WebUtility
    {
    //
    // 摘要:
    // Converts a string that has been HTML-encoded for HTTP transmission into a decoded
    // string.
    //
    // 参数:
    // value:
    // The string to decode.
    //
    // 返回结果:
    // A decoded string.
    public static string HtmlDecode(string value);
    //
    // 摘要:
    // Converts a string that has been HTML-encoded into a decoded string, and sends
    // the decoded string to a System.IO.TextWriter output stream.
    //
    // 参数:
    // value:
    // The string to decode.
    //
    // output:
    // A System.IO.TextWriter stream of output.
    //
    // 异常:
    // T:System.ArgumentNullException:
    // The output parameter cannot be null if the value parameter is not null.
    public static void HtmlDecode(string value, TextWriter output);
    //
    // 摘要:
    // Converts a string to an HTML-encoded string.
    //
    // 参数:
    // value:
    // The string to encode.
    //
    // 返回结果:
    // An encoded string.
    public static string HtmlEncode(string value);
    //
    // 摘要:
    // Converts a string into an HTML-encoded string, and returns the output as a System.IO.TextWriter
    // stream of output.
    //
    // 参数:
    // value:
    // The string to encode.
    //
    // output:
    // A System.IO.TextWriter output stream.
    //
    // 异常:
    // T:System.ArgumentNullException:
    // The output parameter cannot be null if the value parameter is not null.
    public static void HtmlEncode(string value, TextWriter output);
    //
    // 摘要:
    // Converts a string that has been encoded for transmission in a URL into a decoded
    // string.
    //
    // 参数:
    // encodedValue:
    // A URL-encoded string to decode.
    //
    // 返回结果:
    // Returns System.String. A decoded string.
    public static string UrlDecode(string encodedValue);
    //
    // 摘要:
    // Converts an encoded byte array that has been encoded for transmission in a URL
    // into a decoded byte array.
    //
    // 参数:
    // encodedValue:
    // A URL-encoded System.Byte array to decode.
    //
    // offset:
    // The offset, in bytes, from the start of the System.Byte array to decode.
    //
    // count:
    // The count, in bytes, to decode from the System.Byte array.
    //
    // 返回结果:
    // Returns System.Byte. A decoded System.Byte array.
    public static byte[] UrlDecodeToBytes(byte[] encodedValue, int offset, int count);
    //
    // 摘要:
    // Converts a text string into a URL-encoded string.
    //
    // 参数:
    // value:
    // The text to URL-encode.
    //
    // 返回结果:
    // Returns System.String. A URL-encoded string.
    public static string UrlEncode(string value);
    //
    // 摘要:
    // Converts a byte array into a URL-encoded byte array.
    //
    // 参数:
    // value:
    // The System.Byte array to URL-encode.
    //
    // offset:
    // The offset, in bytes, from the start of the System.Byte array to encode.
    //
    // count:
    // The count, in bytes, to encode from the System.Byte array.
    //
    // 返回结果:
    // Returns System.Byte. An encoded System.Byte array.
    public static byte[] UrlEncodeToBytes(byte[] value, int offset, int count);
    }
    }

  • 相关阅读:
    RAC RMAN 备份 RMAN03009 ORA19504 ORA27040 RMAN06012 channel c3 not allocated 错误分析
    Oracle 发送邮件 存储过程 代码
    RAC 之 RMAN 备份
    Oracle 一次小优化
    RAC 实例不能启动
    Oracle Hint
    RAC 之 RMAN 备份
    远程客户端 访问 ASM 实例
    RAC RMAN 备份 RMAN03009 ORA19504 ORA27040 RMAN06012 channel c3 not allocated 错误分析
    RAC the cluster database(DB_NAME) already exits
  • 原文地址:https://www.cnblogs.com/micro-chen/p/11557838.html
Copyright © 2020-2023  润新知