Edit

Share via


Uri.UnescapeDataString Method

Definition

Overloads

UnescapeDataString(ReadOnlySpan<Char>)

Converts a span to its unescaped representation.

UnescapeDataString(String)

Converts a string to its unescaped representation.

UnescapeDataString(ReadOnlySpan<Char>)

Converts a span to its unescaped representation.

C#
public static string UnescapeDataString(ReadOnlySpan<char> charsToUnescape);

Parameters

charsToUnescape
ReadOnlySpan<Char>

The span to unescape.

Returns

The unescaped representation of charsToUnescape.

Applies to

.NET 10 and .NET 9
Product Versions
.NET 9, 10

UnescapeDataString(String)

Source:
UriExt.cs
Source:
UriExt.cs
Source:
UriExt.cs

Converts a string to its unescaped representation.

C#
public static string UnescapeDataString(string stringToUnescape);

Parameters

stringToUnescape
String

The string to unescape.

Returns

The unescaped representation of stringToUnescape.

Exceptions

stringToUnescape is null.

Examples

The following code example unescapes a URI, and then converts any plus characters ("+") into spaces.

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

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

Remarks

You should use this method with care. Unescaping a string that has been previously unescaped can lead to ambiguities and errors.

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.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0