C# Char ConvertFromUtf32

Description

Char ConvertFromUtf32 converts the specified Unicode code point into a UTF-16 encoded string.

Syntax

Char.ConvertFromUtf32 has the following syntax.


public static string ConvertFromUtf32(
  int utf32
)

Parameters

Char.ConvertFromUtf32 has the following parameters.

  • utf32 - A 21-bit Unicode code point.

Returns

Char.ConvertFromUtf32 method returns A string consisting of one Char object or a surrogate pair of Char objects equivalent to the code point specified by the utf32 parameter.

Example

The following code example demonstrates the ConvertFromUtf32 methods.


using System;/*from   w w  w  . ja  v a 2  s .c  om*/

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 UTF-16 encoded string from a code point.");
        s1 = Char.ConvertFromUtf32(letterA);
        Console.Write("    1a) 0x{0:X} => ", letterA);
        Show(s1);
    }
    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