Uri.IsHexEncoding(String, Int32) 方法

定义

确定字符串中的一个字符是否为十六进制编码。

public:
 static bool IsHexEncoding(System::String ^ pattern, int index);
public static bool IsHexEncoding (string pattern, int index);
static member IsHexEncoding : string * int -> bool
Public Shared Function IsHexEncoding (pattern As String, index As Integer) As Boolean

参数

pattern
String

要检查的字符串。

index
Int32

检查十六进制编码的 pattern 中的位置。

返回

如果 pattern 在指定位置进行了十六进制编码,则该值为 true;否则为 false

示例

下面的代码示例确定字符是否是十六进制编码的,如果是,则向控制台写入等效字符。

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

注解

方法 IsHexEncoding 检查字符串中遵循模式“%hexhex”的十六进制编码,其中“hex”是 0 到 9 之间的数字,或来自 A-F (不区分大小写) 的字母。

适用于