Uri.EscapeUriString(String) Uri.EscapeUriString(String) Uri.EscapeUriString(String) Uri.EscapeUriString(String) Method

定义

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

public:
 static System::String ^ EscapeUriString(System::String ^ stringToEscape);
public static string EscapeUriString (string stringToEscape);
static member EscapeUriString : string -> string
Public Shared Function EscapeUriString (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.

注解

使用EscapeUriString方法以准备要进行的参数未转义的 URI 字符串Uri构造函数。Use the EscapeUriString method to prepare an unescaped URI string to be a parameter to the Uri constructor.

默认情况下,EscapeUriString方法将 RFC 2396 非保留字符以外的所有字符都转换为其十六进制表示形式。By default, the EscapeUriString method converts all characters, except RFC 2396 unreserved characters, to their hexadecimal representation. 如果启用了国际资源标识符 (Iri) 或国际化域名 (IDN) 分析,EscapeUriString方法的所有字符转换,除了 RFC 3986 非保留的字符,为其十六进制表示形式。If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the EscapeUriString 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.

适用于