Uri.HexUnescape(String, Int32) Method

Definition

將字元的指定十六進位表示轉換成字元。Converts a specified hexadecimal representation of a character to the character.

public:
 static char HexUnescape(System::String ^ pattern, int % index);
public static char HexUnescape (string pattern, ref int index);
static member HexUnescape : string * int -> char
Public Shared Function HexUnescape (pattern As String, ByRef index As Integer) As Char

Parameters

pattern
String

字元的十六進位表示。The hexadecimal representation of a character.

index
Int32

pattern 中的位置,字元的十六進位表示由此開始。The location in pattern where the hexadecimal representation of a character begins.

Returns

Char

在位置 index 時,字元會以十六進位編碼方式。The character represented by the hexadecimal encoding at position index. 如果在 index 的字元不是以十六進位編碼方式表示,就會傳回位於 index 的字元。If the character at index is not hexadecimal encoded, the character at index is returned. index 的值會遞增,以指向傳回之字元後的字元。The value of index is incremented to point to the character following the one returned.

Exceptions

index 小於 0 或大於或等於 pattern 中的字元數。index is less than 0 or greater than or equal to the number of characters in pattern.

Remarks

下列程式碼範例會判斷字元是否為十六進位編碼,如果是,則會將對等的字元寫入主控台。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, index ) );
}
else
{
   Console::WriteLine( "The character is not hex encoded" );
}
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");
Dim testString As String = "%75"
Dim index As Integer = 0
If Uri.IsHexEncoding(testString, index) Then
    Console.WriteLine("The character is {0}", Uri.HexUnescape(testString, index))
Else
    Console.WriteLine("The character is not hexadecimal encoded")
End If

Applies to