Uri.EscapeDataString Method

July 28, 2014

Converts a string to its escaped representation.

Namespace:  System
Assembly:  System (in System.dll)

public static string EscapeDataString(
	string stringToEscape
)

Parameters

stringToEscape
Type: System.String
The string to escape.

Return Value

Type: System.String
A String that contains the escaped representation of stringToEscape.

ExceptionCondition
ArgumentNullException

stringToEscape is null.

UriFormatException

The length of stringToEscape exceeds 32766 characters.

The EscapeDataString method converts all characters except for RFC 2396 unreserved characters to their hexadecimal representation. All Unicode characters are converted to UTF-8 format before being escaped.

This method assumes that stringToEscape has no escape sequences in it.

The string is escaped according to RFC 3986. See this RFC for a definition of reserved and unreserved characters.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft