Uri.HexUnescape(String, Int32) 方法

定义

将字符的指定十六进制表示形式转换为字符。

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

参数

pattern
String

字符的十六进制表示形式。

index
Int32

pattern 中字符的十六进制表示形式开始的位置。

返回

用十六进制编码表示的位于 index 的字符。 如果位于 index 的字符不是用十六进制编码的,则返回位于 index 的字符。 index 的值递增以指向跟在返回的字符后面的字符。

例外

index 小于 0,或大于等于 pattern 中的字符数。

注解

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

C#
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");

适用于

产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1