Uri.HexUnescape(String, Int32) 方法

定義

將字元的指定十六進位表示轉換成字元。

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

參數

pattern
String

字元的十六進位表示。

index
Int32

pattern 中的位置,字元的十六進位表示由此開始。

傳回

在位置 index 時,字元會以十六進位編碼方式。 如果在 index 的字元不是以十六進位編碼方式表示,就會傳回位於 index 的字元。 index 的值會遞增,以指向傳回之字元後的字元。

例外狀況

index 小於 0 或大於或等於 pattern 中的字元數。

備註

下列程式碼範例會判斷字元是否為十六進位編碼,如果是的話,會將對等字元寫入主控台。

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");
let testString = "%75"
let mutable index = 0
if Uri.IsHexEncoding(testString, index) then
    printfn $"The character is {Uri.HexUnescape(testString, &index)}"
else
    printfn "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

適用於