Export (0) Print
Expand All

Uri.IsHexEncoding Method

Determines whether a character in a string is hexadecimal encoded.

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

public static bool IsHexEncoding(
	string pattern,
	int index
)

Parameters

pattern
Type: System.String

The string to check.

index
Type: System.Int32

The location in pattern to check for hexadecimal encoding.

Return Value

Type: System.Boolean
A Boolean value that is true if pattern is hexadecimal encoded at the specified location; otherwise, false.

The IsHexEncoding method checks for hexadecimal encoding that follows the pattern "%hexhex" in a string, where "hex" is a digit from 0 to 9 or a letter from A-F (case-insensitive).

The following code example determines whether a character is hexadecimal encoded and, if so, writes the equivalent character to the console.

string testString = "%75";
int index = 0;
if (Uri.IsHexEncoding(testString, index))
     Console.WriteLine("The character is {0}", Uri.HexUnescape(testString, ref index));
else
     Console.WriteLine("The character is not hexadecimal encoded");

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft