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. 如果启用了 "国际资源标识符 (IRIs)" 或 "国际化域名 (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. 如果启用了 "国际资源标识符 (IRIs)" 或 "国际化域名 (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.

适用于