Coder UrlEncode Method (String, String, Boolean)C# API
Encodes a string using percent-encoding, specifying which characters should be encoded (optionally including reserved characters).

Namespace: Facilita.Web
Assembly: clrWebBrowser (in clrWebBrowser.dll) Version: 9.5.5.77 (1.0.0.0)
Syntax

public static string UrlEncode(
	string urlFragment,
	string unsafeCharacters,
	bool encodeReservedCharacters
)

Parameters

urlFragment
Type: System String
The text to percent-encode.
unsafeCharacters
Type: System String
A string containing a list of characters that need to be percent-encoded.
encodeReservedCharacters
Type: System Boolean
true if reserved characters should be encoded.

Return Value

The encoded text.
Remarks

A character in the string will be percent-encoded if:
  • It is outside the printable ASCII range (i.e. is not in the ASCII range 32 to 127) OR
  • It is one of the defined unsafeCharacters OR
  • It is a reserved character, and encodeReservedCharacters has the value true

For more information about percent-encoding, refer to OnlineRFC 3986.

Examples

The following example demonstrates encoding a string.
string encoded = Coder.UrlEncode("search?q=camera", "<>\"%{}|\\^[]` \n\t\r&", true);
// encoded == search%3Fq%3Dcamera
See Also