指定した文字列の指定位置にある文字がサロゲート文字かどうかを示します。
Overloads Public Shared Function IsSurrogate( _
ByVal s As String, _ ByVal index As Integer _) As Boolean
[C#]
public static bool IsSurrogate(strings,intindex);
[C++]
public: static bool IsSurrogate(String* s,intindex);
[JScript]
public static function IsSurrogate(
s : String,index : int) : Boolean;
パラメータ
- s
文字列。 - index
s 内の文字位置。
戻り値
s の index の位置にある文字がサロゲート文字の場合は true 。それ以外の場合は false 。
例外
例外の種類 | 条件 |
---|---|
ArgumentNullException | s が null 参照 (Visual Basic では Nothing) です。 |
ArgumentOutOfRangeException | index が 0 未満か、 s の最後の位置より大きい値です。 |
解説
文字列の文字位置には、0 から始まるインデックスが付けられます。
有効なサロゲート文字は、 UnicodeCategory のカテゴリ Surrogate のメンバです。
サロゲート文字の組み合わせの詳細については、http://www.unicode.org の「Unicode Standard」を参照してください。
使用例
[Visual Basic, C#, C++] IsSurrogate のサンプルを次に示します。
Imports System
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
[C#]
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"
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
int main() {
// - escape params specifying Unicode not implemented in v7.0
Console::WriteLine(Char::IsSurrogate('a')); // Output: "False"
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard
参照
Char 構造体 | Char メンバ | System 名前空間 | Char.IsSurrogate オーバーロードの一覧 | Boolean | String