Edit

Share via


Char.IsSeparator Method

Definition

Indicates whether a Unicode character is categorized as a separator character.

Overloads

IsSeparator(Char)

Indicates whether the specified Unicode character is categorized as a separator character.

IsSeparator(String, Int32)

Indicates whether the character at the specified position in a specified string is categorized as a separator character.

Remarks

The Unicode standard recognizes three subcategories of separators:

Note

The Unicode standard classifies the characters \u000A (LF), \u000C (FF), and \u000D (CR) as control characters (members of the UnicodeCategory.Control category), not as separator characters.

IsSeparator(Char)

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

Indicates whether the specified Unicode character is categorized as a separator character.

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

Parameters

c
Char

The Unicode character to evaluate.

Returns

true if c is a separator character; otherwise, false.

Examples

The following example lists the Char objects that are classified as separator characters.

using namespace System;

int main()
{
   for (int ctr = Convert::ToInt32(Char::MinValue); ctr <= Convert::ToInt32(Char::MaxValue); ctr++)
   {
      wchar_t ch = ctr;
      if (Char::IsSeparator(ch))
         Console::WriteLine("\u{0:X4} ({1})", (int) ch, Char::GetUnicodeCategory(ch).ToString());
   }
}
// The example displays the following output:
//       0020 (SpaceSeparator)
//       u00A0 (SpaceSeparator)
//       u1680 (SpaceSeparator)
//       u180E (SpaceSeparator)
//       u2000 (SpaceSeparator)
//       u2001 (SpaceSeparator)
//       u2002 (SpaceSeparator)
//       u2003 (SpaceSeparator)
//       u2004 (SpaceSeparator)
//       u2005 (SpaceSeparator)
//       u2006 (SpaceSeparator)
//       u2007 (SpaceSeparator)
//       u2008 (SpaceSeparator)
//       u2009 (SpaceSeparator)
//       u200A (SpaceSeparator)
//       u2028 (LineSeparator)
//       u2029 (ParagraphSeparator)
//       u202F (SpaceSeparator)
//       u205F (SpaceSeparator)
//       u3000 (SpaceSeparator)
using System;

public class Class1
{
   public static void Main()
   {
      for (int ctr = (int)(Char.MinValue); ctr <= (int)(Char.MaxValue); ctr++)
      {
         char ch = (Char)ctr;
         if (Char.IsSeparator(ch))
            Console.WriteLine(@"\u{(int)ch:X4} ({Char.GetUnicodeCategory(ch)})");
      }
   }
}
// The example displays the following output:
//       \u0020 (SpaceSeparator)
//       \u00A0 (SpaceSeparator)
//       \u1680 (SpaceSeparator)
//       \u180E (SpaceSeparator)
//       \u2000 (SpaceSeparator)
//       \u2001 (SpaceSeparator)
//       \u2002 (SpaceSeparator)
//       \u2003 (SpaceSeparator)
//       \u2004 (SpaceSeparator)
//       \u2005 (SpaceSeparator)
//       \u2006 (SpaceSeparator)
//       \u2007 (SpaceSeparator)
//       \u2008 (SpaceSeparator)
//       \u2009 (SpaceSeparator)
//       \u200A (SpaceSeparator)
//       \u2028 (LineSeparator)
//       \u2029 (ParagraphSeparator)
//       \u202F (SpaceSeparator)
//       \u205F (SpaceSeparator)
//       \u3000 (SpaceSeparator)
open System

for char in Char.MinValue..Char.MaxValue do
    if Char.IsSeparator char then    
        printfn $@"\u{int char:X4} ({Char.GetUnicodeCategory char})"

// The example displays the following output:
//       \u0020 (SpaceSeparator)
//       \u00A0 (SpaceSeparator)
//       \u1680 (SpaceSeparator)
//       \u180E (SpaceSeparator)
//       \u2000 (SpaceSeparator)
//       \u2001 (SpaceSeparator)
//       \u2002 (SpaceSeparator)
//       \u2003 (SpaceSeparator)
//       \u2004 (SpaceSeparator)
//       \u2005 (SpaceSeparator)
//       \u2006 (SpaceSeparator)
//       \u2007 (SpaceSeparator)
//       \u2008 (SpaceSeparator)
//       \u2009 (SpaceSeparator)
//       \u200A (SpaceSeparator)
//       \u2028 (LineSeparator)
//       \u2029 (ParagraphSeparator)
//       \u202F (SpaceSeparator)
//       \u205F (SpaceSeparator)
//       \u3000 (SpaceSeparator)
Module Example
   Public Sub Main()
      For ctr As Integer = Convert.ToInt32(Char.MinValue) To Convert.ToInt32(Char.MaxValue)
         Dim ch As Char = ChrW(ctr)
         If Char.IsSeparator(ch) Then
            Console.WriteLine("\u{0:X4} ({1})", AscW(ch), Char.GetUnicodeCategory(ch).ToString())
         End If
      Next
   End Sub
End Module
' The example displays the following output:
'       \u0020 (SpaceSeparator)
'       \u00A0 (SpaceSeparator)
'       \u1680 (SpaceSeparator)
'       \u180E (SpaceSeparator)
'       \u2000 (SpaceSeparator)
'       \u2001 (SpaceSeparator)
'       \u2002 (SpaceSeparator)
'       \u2003 (SpaceSeparator)
'       \u2004 (SpaceSeparator)
'       \u2005 (SpaceSeparator)
'       \u2006 (SpaceSeparator)
'       \u2007 (SpaceSeparator)
'       \u2008 (SpaceSeparator)
'       \u2009 (SpaceSeparator)
'       \u200A (SpaceSeparator)
'       \u2028 (LineSeparator)
'       \u2029 (ParagraphSeparator)
'       \u202F (SpaceSeparator)
'       \u205F (SpaceSeparator)
'       \u3000 (SpaceSeparator)

Remarks

The Unicode standard recognizes three subcategories of separators:

Note

The Unicode standard classifies the characters \u000A (LF), \u000C (FF), and \u000D (CR) as control characters (members of the UnicodeCategory.Control category), not as separator characters.

See also

Applies to

IsSeparator(String, Int32)

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

Indicates whether the character at the specified position in a specified string is categorized as a separator character.

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

Parameters

s
String

A string.

index
Int32

The position of the character to evaluate in s.

Returns

true if the character at position index in s is a separator character; otherwise, false.

Exceptions

index is less than zero or greater than the last position in s.

Examples

The following example demonstrates IsSeparator.

using namespace System;
int main()
{
   String^ str =  "twain1 twain2";
   Console::WriteLine( Char::IsSeparator( 'a' ) ); // Output: "False"
   Console::WriteLine( Char::IsSeparator( str, 6 ) ); // Output: "True"
}
using System;

public class IsSeparatorSample {
    public static void Main() {
        string str = "twain1 twain2";

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

let str = "twain1 twain2"

printfn $"{Char.IsSeparator 'a'}"       // Output: "False"
printfn $"{Char.IsSeparator(str, 6)}"   // Output: "True"
Module IsSeparatorSample

    Sub Main()

        Dim str As String
        str = "twain1 twain2"

        Console.WriteLine(Char.IsSeparator("a"c))       ' Output: "False"
        Console.WriteLine(Char.IsSeparator(str, 6))     ' Output: "True"

    End Sub

End Module

Remarks

Character positions in a string are indexed starting from zero.

The Unicode standard recognizes three subcategories of separators:

Note

The Unicode standard classifies the characters \u000A (LF), \u000C (FF), and \u000D (CR) as control characters (members of the UnicodeCategory.Control category), not as separator characters.

See also

Applies to