Uri.IsHexEncoding(String, Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定字符串中的字符是否经过十六进制编码。
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 。
返回
true 如果在 pattern 指定位置编码十六进制,则为 ;否则为 false。
示例
下面的代码示例确定字符是否经过十六进制编码,如果是,则向控制台写入等效字符。
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”的十六进制编码,其中“十六进制”是介于 0 到 9 之间的数字或 A-F(不区分大小写)的字母。