不用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);
}
}

C# HtmlDecode、HtmlEncode、UrlEncode、UrlDecode的更多相关文章

  1. Server.UrlEncode、HttpUtility.UrlDecode的区别

    Server.UrlEncode.HttpUtility.UrlDecode的区别 在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗? 测试: string file="文件上(传 ...

  2. Delphi UTF编码 UTF8Encode、UTF8Decode、URLEncode、URLDecode

    一.URL简介    URL是网页的地址,比如 http://www.cnblogs.com.Web 浏览器通过 URL 从 web 服务器请求页面.    由于URL字符串常常会包含非ASCII字符 ...

  3. 各种加密解密函数(URL加密解密、sha1加密解密、des加密解密)

    原文:各种加密解密函数(URL加密解密.sha1加密解密.des加密解密) 普通hash函数如md5.sha1.base64等都是不可逆函数.虽然我们利用php可以利用这些函数写出可逆函数来.但是跨语 ...

  4. PHP获取cookie、Token、模拟登录、抓取数据、解析生成json

    本文介绍使用PHP获取cookie,获取Token.以及模拟登录.然后抓取数据.最后解析生成json的的过程. 0. 设置Cookie路径 set_time_limit(0); //使用的cookie ...

  5. python Django教程 之模板渲染、循环、条件判断、常用的标签、过滤器

    python3.5 manage.py runserver python Django教程 之模板渲染.循环.条件判断.常用的标签.过滤器 一.Django模板渲染模板 1. 创建一个 zqxt_tm ...

  6. 微信公众号开发系统入门教程(公众号注册、开发环境搭建、access_token管理、Demo实现、natapp外网穿透)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/a1786223749/article/ ...

  7. Django drf:cbv源码、resful规范及接口、drf使用、response源码、序列化

    一.cbv源码分析 二.resful规范 三.django中写resful的借口 四.drf写resful的借口 五.APIVIew源码分析 六.drf之序列化 一.cbv源码分析 -CBV和FBV ...

  8. day 87 DjangoRestFramework学习一之restful规范、APIview、解析器组件、Postman等

    DjangoRestFramework学习一之restful规范.APIview.解析器组件.Postman等   本节目录 一 预备知识 二 restful规范 三 DRF的APIView和解析器组 ...

  9. 基础篇-http协议《http 简介、url详解、request》

    目录 一.http 简介 二.url 详解 三.request 1.get 和 post 2.请求方法 3.request 组成 4.请求头 5.get 请求参数 6.post 请求参数 7.post ...

  10. .NET 基础 一步步 一幕幕[面向对象之方法、方法的重载、方法的重写、方法的递归]

    方法.方法的重载.方法的重写.方法的递归 方法: 将一堆代码进行重用的一种机制. 语法: [访问修饰符] 返回类型 <方法名>(参数列表){ 方法主体: } 返回值类型:如果不需要写返回值 ...

随机推荐

  1. day 04 作业 预科

    目录 作业 1.分别列出 数字类型.字符串类型.列表.字典 的 作用.定义方式和使用方法. 数字类型 字符串类型 列表 字典 词云图 作业 1.分别列出 数字类型.字符串类型.列表.字典 的 作用.定 ...

  2. Linux设备管理——sysfs、udev

    What is the use of Sysfs sysfs is a pseudo file system provided by the Linux kernel that exports inf ...

  3. HTML&CSS基础-内联框架

    HTML&CSS基础-内联框架 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.如下图所示,在同一个路径中有两个网页 <!DOCTYPE html> < ...

  4. HTML&CSS基础-标签的属性

    HTML&CSS基础-标签的属性 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.html源代码 <!-- html 根标签,一个页面中有且只有一个根标签,网页中的 ...

  5. 洛谷 P1443 马的遍历题解

    题目链接:https://www.luogu.org/problem/P1443 题目描述 有一个n*m的棋盘(1<n,m<=400),在某个点上有一个马,要求你计算出马到达棋盘上任意一个 ...

  6. scrapy框架爬取糗妹妹网站妹子图分类的所有图片

    爬取所有图片,一个页面的图片建一个文件夹.难点,图片中有不少.gif图片,需要重写下载规则, 创建scrapy项目 scrapy startproject qiumeimei 创建爬虫应用 cd qi ...

  7. 通过ip找mac

    # coding:utf-8 import os cmd = {'arp': 'arp -a | find "', 'route': 'route PRINT ' } def win_mac ...

  8. test20190925 老L

    100+0+0=100.概率题套路见的太少了,做题策略不是最优的. 排列 给出 n 个二元组,第 i 个二元组为(ai,bi). 将 n 个二元组按照一定顺序排成一列,可以得到一个排列.显然,这样的排 ...

  9. EventWaitHandle 第一课

    本篇通过一个列子使用EventWaitHandle实现两个线程的同步.请参看下面的列子. using System; using System.Collections.Generic; using S ...

  10. RDD的Lineage血统

    1.RDD血统:数据容错,发生错误,可以进行重算恢复.Lineage记录的是特定数据的 Transformation 转换操作. 为了保证RDD中数据的鲁棒性,RDD数据集通过所谓的血统关系(Line ...