C# Uri HexUnescape

Description

Uri HexUnescape converts a specified hexadecimal representation of a character to the character.

Syntax

Uri.HexUnescape has the following syntax.


public static char HexUnescape(
  string pattern,
  ref int index
)

Parameters

Uri.HexUnescape has the following parameters.

  • pattern - The hexadecimal representation of a character.
  • index - The location in pattern where the hexadecimal representation of a character begins.

Returns

Uri.HexUnescape method returns The character represented by the hexadecimal encoding at position index. If the character at index is not hexadecimal encoded, the character at index is returned. The value of index is incremented to point to the character following the one returned.

Example

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


//w ww.  j a  v  a 2 s . co m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    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");
    
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version