Char.IsSurrogate 方法

定義

指出字元是否有 Surrogate 字碼單位。

多載

IsSurrogate(Char)

指出指定的字元是否有 Surrogate 字碼單位。

IsSurrogate(String, Int32)

指出位於指定的字串中指定位置處的字元是否有 Surrogate 字碼單位。

範例

下列範例會示範 IsSurrogate 方法。

using namespace System;
int main()
{
   
   // - escape params specifying Unicode not implemented in v7.0
   Console::WriteLine( Char::IsSurrogate( 'a' ) ); // Output: "False"
}
using System;

public class IsSurrogateSample {
    public static void Main() {
        string str = "\U00010F00"; // Unicode values between 0x10000 and 0x10FFF are represented by two 16-bit "surrogate" characters

        Console.WriteLine(Char.IsSurrogate('a'));		// Output: "False"
        Console.WriteLine(Char.IsSurrogate(str, 0));	// Output: "True"
    }
}
open System

let str = "\U00010F00" // Unicode values between 0x10000 and 0x10FFF are represented by two 16-bit "surrogate" characters

printfn $"{Char.IsSurrogate 'a'}"       // Output: "False"
printfn $"{Char.IsSurrogate(str, 0)}"   // Output: "True"
Module IsSurrogateSample

    Sub Main()

        ' NOTE: Visual Basic doesn't give us a way to create a 32-bit Unicode 
        ' character composed of two 16-bit surrogate values, so a case where 
        ' IsSurrogate returns True cannot be included in this sample. 

        Console.WriteLine(Char.IsSurrogate("a"c))       ' Output: "False"

    End Sub

End Module

IsSurrogate(Char)

指出指定的字元是否有 Surrogate 字碼單位。

public:
 static bool IsSurrogate(char c);
public static bool IsSurrogate (char c);
static member IsSurrogate : char -> bool
Public Shared Function IsSurrogate (c As Char) As Boolean

參數

c
Char

要評估的 Unicode 字元。

傳回

Boolean

true 為高 Surrogate 或低 Surrogate 時為 c,否則為 false

備註

代理是一個 Char 物件,其具有 utf-16 程式碼單位,範圍從 U + D800 到 u + DFFF。 此範圍中具有程式碼單位的每個字元都屬於 UnicodeCategory.Surrogate 類別目錄。 個別的代理程式碼單位沒有本身的解釋,但只有在當做代理組的一部分使用時才有意義。 如需有關代理配對的詳細資訊,請參閱 unicode首頁上的 unicode 標準。

另請參閱

適用於

IsSurrogate(String, Int32)

指出位於指定的字串中指定位置處的字元是否有 Surrogate 字碼單位。

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

參數

s
String

字串。

index
Int32

要評估的字元在 s 中的位置。

傳回

Boolean

true 中位於 index 的字元為高 Surrogate 或低 Surrogate 時為 s,否則為 false

例外狀況

snull

index 小於零或大於 s 中的最後一個位置。

備註

字串中的字元位置會從零開始編制索引。

代理是一個 Char 物件,其具有 utf-16 程式碼單位,範圍從 U + D800 到 u + DFFF。 此範圍中具有程式碼單位的每個字元都屬於 UnicodeCategory.Surrogate 類別目錄。 個別的代理程式碼單位沒有本身的解釋,但只有在當做代理組的一部分使用時才有意義。 如需有關代理配對的詳細資訊,請參閱 unicode首頁上的 unicode 標準。

另請參閱

適用於