Uri.EscapeDataString(String) Uri.EscapeDataString(String) Uri.EscapeDataString(String) Uri.EscapeDataString(String) Method

定义

将字符串转换为它的转义表示形式。Converts a string to its escaped representation.

public:
 static System::String ^ EscapeDataString(System::String ^ stringToEscape);
public static string EscapeDataString (string stringToEscape);
static member EscapeDataString : string -> string
Public Shared Function EscapeDataString (stringToEscape As String) As String

参数

stringToEscape
String String String String

要转义的字符串。The string to escape.

返回

一个 String,包含 stringToEscape 的转义表示形式。A String that contains the escaped representation of stringToEscape.

异常

适用于 Windows 应用商店应用的 .NET可移植类库中,改为捕获基类异常 FormatExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, FormatException, instead.

stringToEscape 的长度超过 32766 个字符。The length of stringToEscape exceeds 32766 characters.

注解

默认情况下,EscapeDataString方法将 RFC 2396 非保留字符除外的所有字符都转换为其十六进制表示形式。By default, the EscapeDataString method converts all characters except for RFC 2396 unreserved characters to their hexadecimal representation. 如果启用了国际资源标识符 (Iri) 或国际化域名 (IDN) 分析,EscapeDataString方法的所有字符转换,除了 RFC 3986 非保留的字符,为其十六进制表示形式。If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the EscapeDataString method converts all characters, except for RFC 3986 unreserved characters, to their hexadecimal representation. 转义之前,所有 Unicode 字符都转换为 utf-8 格式。All Unicode characters are converted to UTF-8 format before being escaped.

此方法假定stringToEscape中有任何转义序列。This method assumes that stringToEscape has no escape sequences in it.

默认情况下,根据 RFC 2396 转义字符串。By default, the string is escaped according to RFC 2396. 如果启用了国际资源标识符 (Iri) 或国际化域名 (IDN) 分析,根据 RFC 3986 和 RFC 3987 转义字符串。If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the string is escaped according to RFC 3986 and RFC 3987. 请参阅有关的保留和非保留字符定义这些 Rfc。See these RFCs for a definition of reserved and unreserved characters.

IRI 支持的详细信息,请参阅备注部分Uri类。For more information on IRI support, see the Remarks section for the Uri class.

适用于