Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting chinese character to Unicode

Let's say I have a random Chinese character, 玩. I want to convert it to Unicode, which would be U+73A9. How could I do this in C#?

like image 236
Mass Avatar asked Aug 26 '10 02:08

Mass


1 Answers

Take myChar as a char referencing your special character...

Console.WriteLine("{0} U+{1:x4} {2}", myChar, (int)myChar, (int)myChar);

Above we're outputting the character itself followed by the Unicode code point and then the integer value.

Reduce the format string and parameters to output only the "U+..." code...

Console.WriteLine("U+{0:x4}", (int)myChar);
like image 186
Allbite Avatar answered Sep 20 '22 10:09

Allbite