Uri.UnescapeDataString(String) Uri.UnescapeDataString(String) Uri.UnescapeDataString(String) Uri.UnescapeDataString(String) Method

定义

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

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

参数

stringToUnescape
String String String String

要恢复原义的字符串。The string to unescape.

返回

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

异常

stringToUnescapenullstringToUnescape is null.

示例

下面的代码示例恢复原义使用 URI,并将任何加号字符 ("+") 为空格。The following code example unescapes a URI, and then converts any plus characters ("+") into spaces.

String DataString = Uri.UnescapeDataString(".NET+Framework");
Console.WriteLine("Unescaped string: {0}", DataString);

String PlusString = DataString.Replace('+',' ');
Console.WriteLine("plus to space string: {0}", PlusString);

注解

应谨慎使用此方法。You should use this method with care. 非转义已被以前未转义的字符串可能会导致二义性和错误。Unescaping a string that has been previously unescaped can lead to ambiguities and errors.

许多 Web 浏览器到加号转义 Uri 内的空格 ("+") 字符;但是,UnescapeDataString 方法不会不加上字符组成将转换为空格因为此行为不是标准跨所有 URI 方案。Many Web browsers escape spaces inside of URIs into plus ("+") characters; however, the UnescapeDataString method does not convert plus characters into spaces because this behavior is not standard across all URI schemes.

适用于

另请参阅