UTF-16 Character

.Net framework uses UTF-16 to store strings and characters.

In UTF-16 characters occupy one or two 16 bits storage, while char type in C# only uses one 16 bits.

Two-16-bits characters are called surrogates.

The following code shows how to check if a char is a surrogate.


using System;
using System.Text;
class Sample
{
    public static void Main()
    {
        char ch = 'a';
        Console.WriteLine(char.IsSurrogate(ch));

    }
}

The output:


False
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.