C# में Char.ConvertToUtf32(String, Int32) मेथड का उपयोग एक स्ट्रिंग में निर्दिष्ट स्थिति पर UTF-16 एन्कोडेड वर्ण या सरोगेट जोड़ी के मान को एक यूनिकोड कोड पॉइंट में परिवर्तित करने के लिए किया जाता है।
सिंटैक्स
निम्नलिखित सिंटैक्स है -
public static int ConvertToUtf32 (string str, int index);
यहां, str वह स्ट्रिंग है जिसमें एक वर्ण या सरोगेट जोड़ी होती है। इंडेक्स पैरामीटर str में वर्ण या सरोगेट जोड़ी की इंडेक्स स्थिति है।
उदाहरण
आइए Char.ConvertToUtf32(String, Int32) मेथड को लागू करने का एक उदाहरण देखते हैं -
using System;
public class Demo {
public static void Main(){
int utf = 0x046;
string str = Char.ConvertFromUtf32(utf);
Console.WriteLine("Final Value = "+str);
int res = Char.ConvertToUtf32(str, 0);
Console.WriteLine("Actual Value = 0x{0:X}", res);
}
}
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Final Value = F Actual Value = 0x46
दूसरा उदाहरण
आइए अब एक और उदाहरण देखते हैं -
using System;
public class Demo {
public static void Main(){
int utf = 0x057;
string str = Char.ConvertFromUtf32(utf);
Console.WriteLine("Final Value = "+str);
int res = Char.ConvertToUtf32(str, 0);
Console.WriteLine("Actual Value = 0x{0:X}", res);
}
}
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Final Value = W Actual Value = 0x57