UTF-16 Character

In this chapter you will learn:

  1. UTF-16 Character
  2. Using Unicode Encoding to Display a Smiley Face

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;/*from java2  s .  com*/
using System.Text;
class Sample
{
    public static void Main()
    {
        char ch = 'a';
        Console.WriteLine(char.IsSurrogate(ch));

    }
}

The output:

Smiley Face

class MainClass//from  ja va  2 s .c o  m
{
  static void Main()
  {

    System.Console.Write('\u003A');
    System.Console.WriteLine('\u0029');

  }
}

Next chapter...

What you will learn in the next chapter:

  1. C# integer types
Home » C# Tutorial » bool, char
bool
bool and if statement
bool value to string
Parse string to bool value
char type
char escape sequence
char case
Compare char value
char min/max value
Is char a digit
Is char a letter
Is char a symbol
Is char a Separator
Is char white space
Convert to char
UTF-16 Character