Char.IsControl 메서드

정의

지정된 유니코드 문자가 컨트롤 문자로 분류되는지 여부를 나타냅니다.

오버로드

Name Description
IsControl(Char)

지정된 유니코드 문자가 컨트롤 문자로 분류되는지 여부를 나타냅니다.

IsControl(String, Int32)

지정된 문자열의 지정된 위치에 있는 문자가 컨트롤 문자로 분류되는지 여부를 나타냅니다.

설명

컨트롤 문자는 서식 및 기타 인쇄되지 않는 문자(예: ACK, BEL, CR, FF, LF 및 VT)입니다. 유니코드 표준은 \U0000에서 \U001F, \U007F 및 \U0080에서 \U009F로 코드 포인트를 할당하여 문자를 제어합니다. 유니코드 표준에 따르면 이러한 값은 애플리케이션에서 사용하지 않는 한 컨트롤 문자로 해석되어야 합니다. 유효한 컨트롤 문자는 범주의 멤버입니다 UnicodeCategory.Control .

IsControl(Char)

Source:
Char.cs
Source:
Char.cs
Source:
Char.cs
Source:
Char.cs
Source:
Char.cs

지정된 유니코드 문자가 컨트롤 문자로 분류되는지 여부를 나타냅니다.

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

매개 변수

c
Char

평가할 유니코드 문자입니다.

반품

컨트롤 문자이면 />이고, 그렇지 않으면 .입니다.

예제

다음 예제에서는 각 컨트롤 문자의 유니코드 코드 지점을 나열합니다.

using System;

public class ControlChars
{
   public static void Main()
   {
      int charsWritten = 0;

      for (int ctr = 0x00; ctr <= 0xFFFF; ctr++)
      {
         char ch = Convert.ToChar(ctr);
         if (char.IsControl(ch))
         {
            Console.Write(@"\U{0:X4}    ", ctr);
            charsWritten++;
            if (charsWritten % 6 == 0)
               Console.WriteLine();
         }
      }
   }
}
// The example displays the following output to the console:
//       \U0000    \U0001    \U0002    \U0003    \U0004    \U0005
//       \U0006    \U0007    \U0008    \U0009    \U000A    \U000B
//       \U000C    \U000D    \U000E    \U000F    \U0010    \U0011
//       \U0012    \U0013    \U0014    \U0015    \U0016    \U0017
//       \U0018    \U0019    \U001A    \U001B    \U001C    \U001D
//       \U001E    \U001F    \U007F    \U0080    \U0081    \U0082
//       \U0083    \U0084    \U0085    \U0086    \U0087    \U0088
//       \U0089    \U008A    \U008B    \U008C    \U008D    \U008E
//       \U008F    \U0090    \U0091    \U0092    \U0093    \U0094
//       \U0095    \U0096    \U0097    \U0098    \U0099    \U009A
//       \U009B    \U009C    \U009D    \U009E    \U009F
open System

let mutable charsWritten = 0

for i in 0x00..0xFFFF do
    let ch = Convert.ToChar i
    if Char.IsControl ch then
        printf $"\\U{i:X4}    "
        charsWritten <- charsWritten + 1
        if charsWritten % 6 = 0 then
            printfn ""

// The example displays the following output to the console:
//       \U0000    \U0001    \U0002    \U0003    \U0004    \U0005
//       \U0006    \U0007    \U0008    \U0009    \U000A    \U000B
//       \U000C    \U000D    \U000E    \U000F    \U0010    \U0011
//       \U0012    \U0013    \U0014    \U0015    \U0016    \U0017
//       \U0018    \U0019    \U001A    \U001B    \U001C    \U001D
//       \U001E    \U001F    \U007F    \U0080    \U0081    \U0082
//       \U0083    \U0084    \U0085    \U0086    \U0087    \U0088
//       \U0089    \U008A    \U008B    \U008C    \U008D    \U008E
//       \U008F    \U0090    \U0091    \U0092    \U0093    \U0094
//       \U0095    \U0096    \U0097    \U0098    \U0099    \U009A
//       \U009B    \U009C    \U009D    \U009E    \U009F
Module ControlChars
   Public Sub Main()
      Dim charsWritten As Integer = 0

      For ctr As Integer = &H0 To &HFFFF
         Dim ch As Char = Convert.ToChar(ctr)
         
         If Char.IsControl(ch) Then
            Console.Write("\U{0:X4}    ", ctr)
            charsWritten += 1 
            If (charsWritten Mod 6) = 0 Then 
               Console.WriteLine()
            End If    
         End If
      Next
   End Sub
End Module
' The example displays the following output to the console:
'       \U0000    \U0001    \U0002    \U0003    \U0004    \U0005
'       \U0006    \U0007    \U0008    \U0009    \U000A    \U000B
'       \U000C    \U000D    \U000E    \U000F    \U0010    \U0011
'       \U0012    \U0013    \U0014    \U0015    \U0016    \U0017
'       \U0018    \U0019    \U001A    \U001B    \U001C    \U001D
'       \U001E    \U001F    \U007F    \U0080    \U0081    \U0082
'       \U0083    \U0084    \U0085    \U0086    \U0087    \U0088
'       \U0089    \U008A    \U008B    \U008C    \U008D    \U008E
'       \U008F    \U0090    \U0091    \U0092    \U0093    \U0094
'       \U0095    \U0096    \U0097    \U0098    \U0099    \U009A
'       \U009B    \U009C    \U009D    \U009E    \U009F

적용 대상

IsControl(String, Int32)

Source:
Char.cs
Source:
Char.cs
Source:
Char.cs
Source:
Char.cs
Source:
Char.cs

지정된 문자열의 지정된 위치에 있는 문자가 컨트롤 문자로 분류되는지 여부를 나타냅니다.

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

매개 변수

s
String

문자열입니다.

index
Int32

에서 평가할 문자의 위치입니다.s

반품

true 위치에 index 있는 s 문자가 컨트롤 문자이면 이고, false그렇지 않으면 .

예외

snull입니다.

index 가 0보다 작거나 .의 마지막 위치보다 큽니다 s.

예제

다음 예제에서는 문자열의 문자를 열거하고 컨트롤 문자가 있는지 여부를 확인합니다.

using System;

public class ControlChar
{
   public static void Main()
   {
      string sentence = "This is a " + Environment.NewLine + "two-line sentence.";
      for (int ctr = 0; ctr < sentence.Length; ctr++)
      {
         if (Char.IsControl(sentence, ctr))
           Console.WriteLine("Control character \\U{0} found in position {1}.",
             Convert.ToInt32(sentence[ctr]).ToString("X4"), ctr);
      }
   }
}
// The example displays the following output to the console:
//       Control character \U000D found in position 10.
//       Control character \U000A found in position 11.
open System

let sentence = "This is a " + Environment.NewLine + "two-line sentence."

for i = 0 to sentence.Length - 1 do
    if Char.IsControl(sentence, i) then
        printfn $"Control character \\U{Convert.ToInt32 sentence[i]:X4} found in position {i}."

// The example displays the following output to the console:
//       Control character \U000D found in position 10.
//       Control character \U000A found in position 11.
Module ControlChar
   Public Sub Main()
      Dim sentence As String = "This is a " & vbCrLf & "two-line sentence."
      For ctr As Integer = 0 to sentence.Length - 1
         If Char.IsControl(sentence, ctr) Then
            Console.WriteLine("Control character \U{0} found in position {1}.", _
             Convert.ToInt32(sentence.Chars(ctr)).ToString("X4"), ctr)
          End If
       Next   
   End Sub
End Module
' The example displays the following output to the console:
'       Control character \U000D found in position 10.
'       Control character \U000A found in position 11.

적용 대상