UTF-16 Character
In this chapter you will learn:
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: