HttpEncoder.UrlEncode(Byte[], Int32, Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 URL 中不允许的字符数组编码为等效的十六进制字符实体。
protected public:
virtual cli::array <System::Byte> ^ UrlEncode(cli::array <System::Byte> ^ bytes, int offset, int count);
protected internal virtual byte[] UrlEncode(byte[] bytes, int offset, int count);
abstract member UrlEncode : byte[] * int * int -> byte[]
override this.UrlEncode : byte[] * int * int -> byte[]
Protected Friend Overridable Function UrlEncode (bytes As Byte(), offset As Integer, count As Integer) As Byte()
参数
- bytes
- Byte[]
要编码的字节数组。
- offset
- Int32
数组中 bytes 开始编码的位置。
- count
- Int32
要编码的数组中的 bytes 项数。
返回
编码字符数组。
例外
offset 小于零或大于数组的 bytes 长度。
-或-
count 小于零或 count 加 offset 号大于数组的 bytes 长度。
bytes 是 null。
注解
该方法 UrlEncode 由类中的 HttpUtility 多个 URL 编码方法调用。
方法 UrlEncode URL 对不在被视为 URL 安全的 ASCII 字符集中的任何字符进行编码。 空格编码为 ASCII “+" 字符。 URL 安全的 ASCII 字符包括 ASCII 字符(A 到 Z 和 a to z)、数字(0 到 9),以及一些标点符号。 下表列出了被视为 URL 安全 ASCII 字符的标点符号。
| 字符 | Description |
|---|---|
| - | 连字符 |
| _ | 下划线 |
| 。 | 句点(点) |
| ! | 感叹号 |
| * | 星号 (星号) |
| ( | 左括号 |
| ) | 右括号 |