C# Char ConvertToUtf32(Char, Char)

Description

Char ConvertToUtf32(Char, Char) converts the value of a UTF-16 encoded surrogate pair into a Unicode code point.

Syntax

Char.ConvertToUtf32(Char, Char) has the following syntax.


public static int ConvertToUtf32(
  char highSurrogate,
  char lowSurrogate
)

Parameters

Char.ConvertToUtf32(Char, Char) has the following parameters.

  • highSurrogate - A high surrogate code unit (that is, a code unit ranging from U+D800 through U+DBFF).
  • lowSurrogate - A low surrogate code unit (that is, a code unit ranging from U+DC00 through U+DFFF).

Returns

Char.ConvertToUtf32(Char, Char) method returns The 21-bit Unicode code point represented by the highSurrogate and lowSurrogate parameters.

Example

The following code example demonstrates the ConvertToUtf32 method.


//from   w  w  w .  ja va2 s.c o m
using System;

class Sample 
{
    public static void Main() 
    {
        int letterA = 0x0041;  //U+00041 = LATIN CAPITAL LETTER A 
        int music   = 0x1D161; //U+1D161 = MUSICAL SYMBOL SIXTEENTH NOTE 
        string s1 = "";
   
        Console.WriteLine("Create a code point from a UTF-16 encoded string.");
        letterA = Char.ConvertToUtf32(s1, 0);
        Console.Write("    1b) ");
        Show(s1);
        Console.WriteLine(" => 0x{0:X}", letterA);

    }

    private static void Show(string s){
        for (int x = 0; x < s.Length; x++){
           Console.Write("0x{0:X}{1}", 
                       (int)s[x], 
                       ((x == s.Length-1)? String.Empty : ", "));
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version