Char.IsSurrogate 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示角色是否有替代代碼單元。
多載
| 名稱 | Description |
|---|---|
| IsSurrogate(Char) |
表示指定字元是否有替代代碼單元。 |
| IsSurrogate(String, Int32) |
表示指定字串中指定位置的字元是否擁有替代碼單元。 |
範例
以下範例示範此 IsSurrogate 方法。
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)
- 來源:
- Char.cs
- 來源:
- Char.cs
- 來源:
- Char.cs
- 來源:
- Char.cs
- 來源:
- Char.cs
表示指定字元是否有替代代碼單元。
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 字元。
傳回
true 若 c 是高代詞或低代詞;否則, false。
備註
代理器是指 Char 具有 UTF-16 編碼單元的物件,範圍範圍從 U+D800 到 U+DFFF。 每個在此範圍內有編碼單元的字元都屬於該 UnicodeCategory.Surrogate 類別。 個別替代代碼單元本身沒有解釋,只有作為替代對的一部分使用時才有意義。 欲了解更多關於替代配對的資訊,請參閱 Unicode 首頁的 Unicode 標準。
另請參閱
適用於
IsSurrogate(String, Int32)
- 來源:
- Char.cs
- 來源:
- Char.cs
- 來源:
- Char.cs
- 來源:
- Char.cs
- 來源:
- Char.cs
表示指定字串中指定位置的字元是否擁有替代碼單元。
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評估的字元位置。
傳回
true若 中s位置index的字元是高代詞或低代詞;否則, false
例外狀況
s 為 null。
index 小於零或大於中 s最後一個位置。
備註
字串中的字元位置從零開始索引。
代理器是指 Char 具有 UTF-16 編碼單元的物件,範圍範圍從 U+D800 到 U+DFFF。 每個在此範圍內有編碼單元的字元都屬於該 UnicodeCategory.Surrogate 類別。 個別替代代碼單元本身沒有解釋,只有作為替代對的一部分使用時才有意義。 欲了解更多關於替代配對的資訊,請參閱 Unicode 首頁的 Unicode 標準。