Char.IsSurrogatePair 메서드

정의

지정한 두 개의 Char 개체가 서로게이트 쌍을 형성하는지 여부를 나타냅니다.

오버로드

IsSurrogatePair(String, Int32)

문자열의 지정한 위치에 있는 두 개의 인접한 Char 개체가 서로게이트 쌍을 형성하는지 여부를 나타냅니다.

IsSurrogatePair(Char, Char)

지정한 두 개의 Char 개체가 서로게이트 쌍을 형성하는지 여부를 나타냅니다.

예제

다음 코드 예제에서는 IsHighSurrogate , 및 메서드를 보여 줍니다 IsLowSurrogate IsSurrogatePair .

// This example demonstrates the Char.IsLowSurrogate() method
//                                    IsHighSurrogate() method
//                                    IsSurrogatePair() method
using namespace System;
int main()
{
   Char cHigh = L'\xD800';
   Char cLow = L'\xDC00';
   array<Char>^temp0 = {L'a',L'\xD800',L'\xDC00',L'z'};
   String^ s1 = gcnew String( temp0 );
   String^ divider = String::Concat( Environment::NewLine, gcnew String( '-',70 ), Environment::NewLine );
   Console::WriteLine();
   Console::WriteLine( "Hexadecimal code point of the character, cHigh: {0:X4}", (int)cHigh );
   Console::WriteLine( "Hexadecimal code point of the character, cLow:  {0:X4}", (int)cLow );
   Console::WriteLine();
   Console::WriteLine( "Characters in string, s1: 'a', high surrogate, low surrogate, 'z'" );
   Console::WriteLine( "Hexadecimal code points of the characters in string, s1: " );
   for ( int i = 0; i < s1->Length; i++ )
   {
      Console::WriteLine( "s1[{0}] = {1:X4} ", i, (int)s1[ i ] );
   }
   Console::WriteLine( divider );
   Console::WriteLine( "Is each of the following characters a high surrogate?" );
   Console::WriteLine( "A1) cLow?  - {0}", Char::IsHighSurrogate( cLow ) );
   Console::WriteLine( "A2) cHigh? - {0}", Char::IsHighSurrogate( cHigh ) );
   Console::WriteLine( "A3) s1[0]? - {0}", Char::IsHighSurrogate( s1, 0 ) );
   Console::WriteLine( "A4) s1[1]? - {0}", Char::IsHighSurrogate( s1, 1 ) );
   Console::WriteLine( divider );
   Console::WriteLine( "Is each of the following characters a low surrogate?" );
   Console::WriteLine( "B1) cLow?  - {0}", Char::IsLowSurrogate( cLow ) );
   Console::WriteLine( "B2) cHigh? - {0}", Char::IsLowSurrogate( cHigh ) );
   Console::WriteLine( "B3) s1[0]? - {0}", Char::IsLowSurrogate( s1, 0 ) );
   Console::WriteLine( "B4) s1[2]? - {0}", Char::IsLowSurrogate( s1, 2 ) );
   Console::WriteLine( divider );
   Console::WriteLine( "Is each of the following pairs of characters a surrogate pair?" );
   Console::WriteLine( "C1) cHigh and cLow?  - {0}", Char::IsSurrogatePair( cHigh, cLow ) );
   Console::WriteLine( "C2) s1[0] and s1[1]? - {0}", Char::IsSurrogatePair( s1, 0 ) );
   Console::WriteLine( "C3) s1[1] and s1[2]? - {0}", Char::IsSurrogatePair( s1, 1 ) );
   Console::WriteLine( "C4) s1[2] and s1[3]? - {0}", Char::IsSurrogatePair( s1, 2 ) );
   Console::WriteLine( divider );
}

/*
This example produces the following results:

Hexadecimal code point of the character, cHigh: D800
Hexadecimal code point of the character, cLow:  DC00

Characters in string, s1: 'a', high surrogate, low surrogate, 'z'
Hexadecimal code points of the characters in string, s1:
s1[0] = 0061
s1[1] = D800
s1[2] = DC00
s1[3] = 007A

----------------------------------------------------------------------

Is each of the following characters a high surrogate?
A1) cLow?  - False
A2) cHigh? - True
A3) s1[0]? - False
A4) s1[1]? - True

----------------------------------------------------------------------

Is each of the following characters a low surrogate?
B1) cLow?  - True
B2) cHigh? - False
B3) s1[0]? - False
B4) s1[2]? - True

----------------------------------------------------------------------

Is each of the following pairs of characters a surrogate pair?
C1) cHigh and cLow?  - True
C2) s1[0] and s1[1]? - False
C3) s1[1] and s1[2]? - True
C4) s1[2] and s1[3]? - False

----------------------------------------------------------------------

*/
// This example demonstrates the Char.IsLowSurrogate() method
//                                    IsHighSurrogate() method
//                                    IsSurrogatePair() method
using System;

class Sample
{
    public static void Main()
    {
    char cHigh = '\uD800';
    char cLow  = '\uDC00';
    string s1  = new String(new char[] {'a', '\uD800', '\uDC00', 'z'});
    string divider = String.Concat( Environment.NewLine, new String('-', 70),
                                    Environment.NewLine);

    Console.WriteLine();
    Console.WriteLine("Hexadecimal code point of the character, cHigh: {0:X4}", (int)cHigh);
    Console.WriteLine("Hexadecimal code point of the character, cLow:  {0:X4}", (int)cLow);
    Console.WriteLine();
    Console.WriteLine("Characters in string, s1: 'a', high surrogate, low surrogate, 'z'");
    Console.WriteLine("Hexadecimal code points of the characters in string, s1: ");
    for(int i = 0; i < s1.Length; i++)
        {
        Console.WriteLine("s1[{0}] = {1:X4} ", i, (int)s1[i]);
        }
    Console.WriteLine(divider);

    Console.WriteLine("Is each of the following characters a high surrogate?");
    Console.WriteLine("A1) cLow?  - {0}", Char.IsHighSurrogate(cLow));
    Console.WriteLine("A2) cHigh? - {0}", Char.IsHighSurrogate(cHigh));
    Console.WriteLine("A3) s1[0]? - {0}", Char.IsHighSurrogate(s1, 0));
    Console.WriteLine("A4) s1[1]? - {0}", Char.IsHighSurrogate(s1, 1));
    Console.WriteLine(divider);

    Console.WriteLine("Is each of the following characters a low surrogate?");
    Console.WriteLine("B1) cLow?  - {0}", Char.IsLowSurrogate(cLow));
    Console.WriteLine("B2) cHigh? - {0}", Char.IsLowSurrogate(cHigh));
    Console.WriteLine("B3) s1[0]? - {0}", Char.IsLowSurrogate(s1, 0));
    Console.WriteLine("B4) s1[2]? - {0}", Char.IsLowSurrogate(s1, 2));
    Console.WriteLine(divider);

    Console.WriteLine("Is each of the following pairs of characters a surrogate pair?");
    Console.WriteLine("C1) cHigh and cLow?  - {0}", Char.IsSurrogatePair(cHigh, cLow));
    Console.WriteLine("C2) s1[0] and s1[1]? - {0}", Char.IsSurrogatePair(s1, 0));
    Console.WriteLine("C3) s1[1] and s1[2]? - {0}", Char.IsSurrogatePair(s1, 1));
    Console.WriteLine("C4) s1[2] and s1[3]? - {0}", Char.IsSurrogatePair(s1, 2));
    Console.WriteLine(divider);
    }
}
/*
This example produces the following results:

Hexadecimal code point of the character, cHigh: D800
Hexadecimal code point of the character, cLow:  DC00

Characters in string, s1: 'a', high surrogate, low surrogate, 'z'
Hexadecimal code points of the characters in string, s1:
s1[0] = 0061
s1[1] = D800
s1[2] = DC00
s1[3] = 007A

----------------------------------------------------------------------

Is each of the following characters a high surrogate?
A1) cLow?  - False
A2) cHigh? - True
A3) s1[0]? - False
A4) s1[1]? - True

----------------------------------------------------------------------

Is each of the following characters a low surrogate?
B1) cLow?  - True
B2) cHigh? - False
B3) s1[0]? - False
B4) s1[2]? - True

----------------------------------------------------------------------

Is each of the following pairs of characters a surrogate pair?
C1) cHigh and cLow?  - True
C2) s1[0] and s1[1]? - False
C3) s1[1] and s1[2]? - True
C4) s1[2] and s1[3]? - False

----------------------------------------------------------------------

*/
// This example demonstrates the Char.IsLowSurrogate() method
//                                    IsHighSurrogate() method
//                                    IsSurrogatePair() method
open System

let cHigh = '\uD800'
let cLow  = '\uDC00'
let s1 = String [| 'a'; '\uD800'; '\uDC00'; 'z' |]
let divider = String.Concat(Environment.NewLine, String('-', 70), Environment.NewLine)

printfn $"""
Hexadecimal code point of the character, cHigh: {int cHigh:X4}
Hexadecimal code point of the character, cLow:  {int cLow:X4}

Characters in string, s1: 'a', high surrogate, low surrogate, 'z'
Hexadecimal code points of the characters in string, s1: """

for i = 0 to s1.Length - 1 do
    printfn $"s1[{i}] = {int s1[i]:X4} "

printfn $"""{divider}
Is each of the following characters a high surrogate?
A1) cLow?  - {Char.IsHighSurrogate cLow}
A2) cHigh? - {Char.IsHighSurrogate cHigh}
A3) s1[0]? - {Char.IsHighSurrogate(s1, 0)}
A4) s1[1]? - {Char.IsHighSurrogate(s1, 1)}
{divider}"""

printfn $"""Is each of the following characters a low surrogate?
B1) cLow?  - {Char.IsLowSurrogate cLow}
B2) cHigh? - {Char.IsLowSurrogate cHigh}
B3) s1[0]? - {Char.IsLowSurrogate(s1, 0)}
B4) s1[2]? - {Char.IsLowSurrogate(s1, 2)}
{divider}"""

printfn $"""Is each of the following pairs of characters a surrogate pair?
C1) cHigh and cLow?  - {Char.IsSurrogatePair(cHigh, cLow)}
C2) s1[0] and s1[1]? - {Char.IsSurrogatePair(s1, 0)}
C3) s1[1] and s1[2]? - {Char.IsSurrogatePair(s1, 1)}
C4) s1[2] and s1[3]? - {Char.IsSurrogatePair(s1, 2)}"
{divider}"""

// This example produces the following results:
//
// Hexadecimal code point of the character, cHigh: D800
// Hexadecimal code point of the character, cLow:  DC00
//
// Characters in string, s1: 'a', high surrogate, low surrogate, 'z'
// Hexadecimal code points of the characters in string, s1:
// s1[0] = 0061
// s1[1] = D800
// s1[2] = DC00
// s1[3] = 007A
//
// ----------------------------------------------------------------------
//
// Is each of the following characters a high surrogate?
// A1) cLow?  - False
// A2) cHigh? - True
// A3) s1[0]? - False
// A4) s1[1]? - True
//
// ----------------------------------------------------------------------
//
// Is each of the following characters a low surrogate?
// B1) cLow?  - True
// B2) cHigh? - False
// B3) s1[0]? - False
// B4) s1[2]? - True
//
// ----------------------------------------------------------------------
//
// Is each of the following pairs of characters a surrogate pair?
// C1) cHigh and cLow?  - True
// C2) s1[0] and s1[1]? - False
// C3) s1[1] and s1[2]? - True
// C4) s1[2] and s1[3]? - False
//
// ----------------------------------------------------------------------
' This example demonstrates the Char.IsLowSurrogate() method
'                                    IsHighSurrogate() method
'                                    IsSurrogatePair() method
Class Sample
   Public Shared Sub Main()
      Dim cHigh As Char = ChrW(&HD800)
      Dim cLow  As Char = ChrW(&HDC00)
      Dim s1 = New [String](New Char() {"a"c, ChrW(&HD800), ChrW(&HDC00), "z"c})
      Dim divider As String = [String].Concat(Environment.NewLine, _
                                              New [String]("-"c, 70), _
                                              Environment.NewLine)
      
      Console.WriteLine()
      Console.WriteLine("Hexadecimal code point of the character, cHigh: {0:X4}", AscW(cHigh))
      Console.WriteLine("Hexadecimal code point of the character, cLow:  {0:X4}", AscW(cLow))
      Console.WriteLine()
      Console.WriteLine("Characters in string, s1: 'a', high surrogate, low surrogate, 'z'")
      Console.WriteLine("Hexadecimal code points of the characters in string, s1: ")
      Dim i As Integer
      For i = 0 To s1.Length - 1
         Console.WriteLine("s1({0}) = {1:X4} ", i, AscW(s1.Chars(i)))
      Next i
      Console.WriteLine(divider)
      
      Console.WriteLine("Is each of the following characters a high surrogate?")
      Console.WriteLine("A1) cLow?  - {0}", [Char].IsHighSurrogate(cLow))
      Console.WriteLine("A2) cHigh? - {0}", [Char].IsHighSurrogate(cHigh))
      Console.WriteLine("A3) s1(0)? - {0}", [Char].IsHighSurrogate(s1, 0))
      Console.WriteLine("A4) s1(1)? - {0}", [Char].IsHighSurrogate(s1, 1))
      Console.WriteLine(divider)
      
      Console.WriteLine("Is each of the following characters a low surrogate?")
      Console.WriteLine("B1) cLow?  - {0}", [Char].IsLowSurrogate(cLow))
      Console.WriteLine("B2) cHigh? - {0}", [Char].IsLowSurrogate(cHigh))
      Console.WriteLine("B3) s1(0)? - {0}", [Char].IsLowSurrogate(s1, 0))
      Console.WriteLine("B4) s1(2)? - {0}", [Char].IsLowSurrogate(s1, 2))
      Console.WriteLine(divider)
      
      Console.WriteLine("Is each of the following pairs of characters a surrogate pair?")
      Console.WriteLine("C1) cHigh and cLow?  - {0}", [Char].IsSurrogatePair(cHigh, cLow))
      Console.WriteLine("C2) s1(0) and s1(1)? - {0}", [Char].IsSurrogatePair(s1, 0))
      Console.WriteLine("C3) s1(1) and s1(2)? - {0}", [Char].IsSurrogatePair(s1, 1))
      Console.WriteLine("C4) s1(2) and s1(3)? - {0}", [Char].IsSurrogatePair(s1, 2))
      Console.WriteLine(divider)
   End Sub
End Class
'
'This example produces the following results:
'
'Hexadecimal code point of the character, cHigh: D800
'Hexadecimal code point of the character, cLow:  DC00
'
'Characters in string, s1: 'a', high surrogate, low surrogate, 'z'
'Hexadecimal code points of the characters in string, s1:
's1(0) = 0061
's1(1) = D800
's1(2) = DC00
's1(3) = 007A
'
'----------------------------------------------------------------------
'
'Is each of the following characters a high surrogate?
'A1) cLow?  - False
'A2) cHigh? - True
'A3) s1(0)? - False
'A4) s1(1)? - True
'
'----------------------------------------------------------------------
'
'Is each of the following characters a low surrogate?
'B1) cLow?  - True
'B2) cHigh? - False
'B3) s1(0)? - False
'B4) s1(2)? - True
'
'----------------------------------------------------------------------
'
'Is each of the following pairs of characters a surrogate pair?
'C1) cHigh and cLow?  - True
'C2) s1(0) and s1(1)? - False
'C3) s1(1) and s1(2)? - True
'C4) s1(2) and s1(3)? - False
'
'----------------------------------------------------------------------
'

IsSurrogatePair(String, Int32)

문자열의 지정한 위치에 있는 두 개의 인접한 Char 개체가 서로게이트 쌍을 형성하는지 여부를 나타냅니다.

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

매개 변수

s
String

문자열

index
Int32

s 내에서 확인할 문자 쌍의 시작 위치입니다.

반환

Boolean

s 매개 변수에 index 위치와 index + 1 위치에 인접한 문자가 포함되고, index 위치에 있는 문자의 숫자 값이 U+D800부터 U+DBFF까지의 범위에 있으며, index+1 위치에 있는 문자의 숫자 값이 U+DC00부터 U+DFFF까지의 범위에 있으면 true이고, 그렇지 않으면 false입니다.

예외

s이(가) null인 경우

indexs 내의 위치가 아닙니다.

설명

일반적으로 단일 문자는 단일 16 비트 유니코드 코드 단위로 표시 됩니다. UTF-16 인코딩은 단일 추상 문자를 2 16 비트 코드 단위로 표현할 수 있는 서로게이트 쌍도 지원 합니다. 값이 U + D 800 U + DBFF 까지의 범위에 있는 첫 번째 코드 단위는 상위 서로게이트입니다. 값이 U + D C 00 U + DFFF 까지의 범위에 포함 될 수 있는 두 번째 코드 단위는 하위 서로게이트입니다. 개별 서로게이트 코드 지점은 자체적으로 해석 되지 않습니다. 서로게이트 및 유니코드 표준에 대 한 자세한 내용은 유니코드 홈 페이지를 참조 하세요.

추가 정보

적용 대상

IsSurrogatePair(Char, Char)

지정한 두 개의 Char 개체가 서로게이트 쌍을 형성하는지 여부를 나타냅니다.

public:
 static bool IsSurrogatePair(char highSurrogate, char lowSurrogate);
public static bool IsSurrogatePair (char highSurrogate, char lowSurrogate);
static member IsSurrogatePair : char * char -> bool
Public Shared Function IsSurrogatePair (highSurrogate As Char, lowSurrogate As Char) As Boolean

매개 변수

highSurrogate
Char

서로게이트 쌍의 high surrogate로 확인할 문자입니다.

lowSurrogate
Char

서로게이트 쌍의 low surrogate로 확인할 문자입니다.

반환

Boolean

highSurrogate 매개 변수의 숫자 값이 U+D800부터 U+DBFF까지의 범위에 있고 lowSurrogate 매개 변수의 숫자 값이 U+DC00부터 U+DFFF까지의 범위에 있으면 true이고, 그렇지 않으면 false입니다.

설명

일반적으로 단일 문자는 단일 16 비트 유니코드 코드 단위로 표시 됩니다. UTF-16 인코딩은 단일 추상 문자를 2 16 비트 코드 단위로 표현할 수 있는 서로게이트 쌍도 지원 합니다. 값이 U + D 800 U + DBFF 까지의 범위에 있는 첫 번째 코드 단위는 상위 서로게이트입니다. 값이 U + D C 00 U + DFFF 까지의 범위에 포함 될 수 있는 두 번째 코드 단위는 하위 서로게이트입니다. 개별 서로게이트 코드 지점은 자체적으로 해석 되지 않습니다. 서로게이트 및 유니코드 표준에 대 한 자세한 내용은 유니코드 홈 페이지를 참조 하세요.

추가 정보

적용 대상