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));
}
}
|