Char.IsLowSurrogate(), IsHighSurrogate(), IsSurrogatePair() method : Char « Data Types « C# / C Sharp






Char.IsLowSurrogate(), IsHighSurrogate(), 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'});
        Console.WriteLine("cHigh: {0:X4}", (int)cHigh);
        Console.WriteLine("cLow:  {0:X4}", (int)cLow);
        for(int i = 0; i < s1.Length; i++){
            Console.WriteLine("{0:X4} ", (int)s1[i]);
        }
        Console.WriteLine("cLow?  - {0}", Char.IsHighSurrogate(cLow));
        Console.WriteLine("cHigh? - {0}", Char.IsHighSurrogate(cHigh));
        Console.WriteLine("s1[0]? - {0}", Char.IsHighSurrogate(s1, 0));
        Console.WriteLine("s1[1]? - {0}", Char.IsHighSurrogate(s1, 1));
    
        Console.WriteLine("cLow?  - {0}", Char.IsLowSurrogate(cLow));
        Console.WriteLine("cHigh? - {0}", Char.IsLowSurrogate(cHigh));
        Console.WriteLine("s1[0]? - {0}", Char.IsLowSurrogate(s1, 0));
        Console.WriteLine("s1[2]? - {0}", Char.IsLowSurrogate(s1, 2));
    
        Console.WriteLine("cHigh and cLow?  - {0}", Char.IsSurrogatePair(cHigh, cLow));
        Console.WriteLine("s1[0] and s1[1]? - {0}", Char.IsSurrogatePair(s1, 0));
        Console.WriteLine("s1[1] and s1[2]? - {0}", Char.IsSurrogatePair(s1, 1));
        Console.WriteLine("s1[2] and s1[3]? - {0}", Char.IsSurrogatePair(s1, 2));
    }
}

   
    
    
  








Related examples in the same category

1.Get char type: control, digit, letter, number, punctuation, surrogate, symbol and white spaceGet char type: control, digit, letter, number, punctuation, surrogate, symbol and white space
2.Determining If A Character Is Within A Specified RangeDetermining If A Character Is Within A Specified Range
3.Is a char in a range: Case InsensitiveIs a char in a range: Case Insensitive
4.Is a char in a range ExclusivelyIs a char in a range Exclusively
5.Using Char
6.Escape Characters
7.A stack class for charactersA stack class for characters
8.Encode or decode a message
9.Demonstrate several Char methodsDemonstrate several Char methods
10.Demonstrate the ICharQ interface: A character queue interfaceDemonstrate the ICharQ interface: A character queue interface
11.A set class for charactersA set class for characters
12.A queue class for charactersA queue class for characters
13.IsDigit, IsLetter, IsWhiteSpace, IsLetterOrDigit, IsPunctuation
14.Char: Get Unicode Category
15.demonstrates IsSymbol.
16.Buffer for characters
17.Test an input character if it is contained in a character list.
18.Is vowel char
19.Filter letter and digit
20.First Char Upper