HttpUtility.UrlEncodeToBytes 方法

定义

将字符串或字节数组转换为编码的字节数组。

若要对 Web 应用程序之外的值进行编码或解码,请使用 WebUtility 类。

重载

UrlEncodeToBytes(Byte[])

将字节数组转换为 URL 编码的字节数组。

UrlEncodeToBytes(String)

将字符串转换为 URL 编码的字节数组。

UrlEncodeToBytes(String, Encoding)

使用指定的编码对象将字符串转换为 URL 编码的字节数组。

UrlEncodeToBytes(Byte[], Int32, Int32)

将字节数组转换为 URL 编码的字节数组,从数组中指定位置开始,以指定字节数继续。

UrlEncodeToBytes(Byte[])

将字节数组转换为 URL 编码的字节数组。

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(cli::array <System::Byte> ^ bytes);
public static byte[]? UrlEncodeToBytes (byte[]? bytes);
public static byte[] UrlEncodeToBytes (byte[] bytes);
static member UrlEncodeToBytes : byte[] -> byte[]
Public Shared Function UrlEncodeToBytes (bytes As Byte()) As Byte()

参数

bytes
Byte[]

要编码的字节数组。

返回

Byte[]

编码的字节数组。

注解

如果在 HTTP 流中传递空白和标点符号等字符,则它们可能会在接收端被误解。 URL 编码将 URL 中不允许的字符转换为字符实体等效项;URL 解码会反转编码。 例如,当嵌入在 URL 中传输的文本块中时,字符 < and > 将编码为 %3c 和 %3e。

若要对 Web 应用程序之外的值进行编码或解码,请使用 WebUtility 类。

另请参阅

适用于

UrlEncodeToBytes(String)

将字符串转换为 URL 编码的字节数组。

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(System::String ^ str);
public static byte[]? UrlEncodeToBytes (string? str);
public static byte[] UrlEncodeToBytes (string str);
static member UrlEncodeToBytes : string -> byte[]
Public Shared Function UrlEncodeToBytes (str As String) As Byte()

参数

str
String

要编码的字符串。

返回

Byte[]

编码的字节数组。

注解

如果在 HTTP 流中传递空白和标点符号等字符,则它们可能会在接收端被误解。 URL 编码将 URL 中不允许的字符转换为字符实体等效项;URL 解码会反转编码。 例如,当嵌入在 URL 中传输的文本块中时,字符 < and > 将编码为 %3c 和 %3e。

若要对 Web 应用程序之外的值进行编码或解码,请使用 WebUtility 类。

另请参阅

适用于

UrlEncodeToBytes(String, Encoding)

使用指定的编码对象将字符串转换为 URL 编码的字节数组。

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(System::String ^ str, System::Text::Encoding ^ e);
public static byte[]? UrlEncodeToBytes (string? str, System.Text.Encoding e);
public static byte[] UrlEncodeToBytes (string str, System.Text.Encoding e);
static member UrlEncodeToBytes : string * System.Text.Encoding -> byte[]
Public Shared Function UrlEncodeToBytes (str As String, e As Encoding) As Byte()

参数

str
String

要编码的字符串。

e
Encoding

指定编码方案的 Encoding

返回

Byte[]

编码的字节数组。

注解

如果在 HTTP 流中传递空白和标点符号等字符,则它们可能会在接收端被误解。 URL 编码将 URL 中不允许的字符转换为字符实体等效项;URL 解码会反转编码。 例如,当嵌入在 URL 中传输的文本块中时,字符 < and > 将编码为 %3c 和 %3e。

若要对 Web 应用程序之外的值进行编码或解码,请使用 WebUtility 类。

另请参阅

适用于

UrlEncodeToBytes(Byte[], Int32, Int32)

将字节数组转换为 URL 编码的字节数组,从数组中指定位置开始,以指定字节数继续。

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(cli::array <System::Byte> ^ bytes, int offset, int count);
public static byte[]? UrlEncodeToBytes (byte[]? bytes, int offset, int count);
public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count);
static member UrlEncodeToBytes : byte[] * int * int -> byte[]
Public Shared Function UrlEncodeToBytes (bytes As Byte(), offset As Integer, count As Integer) As Byte()

参数

bytes
Byte[]

要编码的字节数组。

offset
Int32

从其开始编码的字节数组中的位置。

count
Int32

要编码的字节数。

返回

Byte[]

编码的字节数组。

例外

bytesnull,但是 count 不等于 0

offset 小于 0 或大于 bytes 数组的长度。

  • 或 -

count 小于 0,或 count + offset 大于 bytes 数组的长度。

注解

如果在 HTTP 流中传递空白和标点符号等字符,则它们可能会在接收端被误解。 URL 编码将 URL 中不允许的字符转换为字符实体等效项;URL 解码会反转编码。 例如,当嵌入在 URL 中传输的文本块中时,字符 < and > 将编码为 %3c 和 %3e。

若要对 Web 应用程序之外的值进行编码或解码,请使用 WebUtility 类。

另请参阅

适用于