Uri.IsHexEncoding(String, Int32) メソッド
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
文字列内の文字が 16 進エンコードかどうかを判断します。
public:
static bool IsHexEncoding(System::String ^ pattern, int index);
C#
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
内で 16 進エンコーディングを確認する位置。
pattern
が指定された位置の 16 進エンコードの場合は true
。それ以外の場合は false
。
次のコード例では、文字が 16 進数でエンコードされているかどうかを判断し、エンコードされている場合は、同等の文字をコンソールに書き込みます。
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" );
}
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");
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" に続く 16 進エンコードをチェックします。ここで、"hex" は 0 から 9 までの数字、または A から F の文字 (大文字と小文字は区別されません) です。
製品 | バージョン |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 |
.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 |
.NET Standard | 2.0, 2.1 |