0

= (\ud835\udc00) in UTF16

How do I do this conversion in C#?

The following code doesn't allow me to enter the character above. It throws the error "Too many characters in character literal" I guess it's because the char is multi point.

string hex = ((int)'').ToString("X4");
string hex = ((int)'A').ToString("X4");// This works

A help would be much appreciated!

Heshan
  • 913
  • 8
  • 30
  • Check this similar questions answered here. [I think this may help you](https://stackoverflow.com/questions/11293994/how-to-convert-a-utf-8-string-into-unicode/14775141#14775141) – Shivshanker Cheral May 21 '20 at 05:35
  • Check this similar questions answered here. [I think this may help you](https://stackoverflow.com/questions/11293994/how-to-convert-a-utf-8-string-into-unicode/14775141#14775141) – Shivshanker Cheral May 21 '20 at 05:37
  • Here are some dotNet/PowerShell hints (I'm too lazy converting them to C#). `[char[]]''|ForEach-Object{([int]$_).ToString("X4")}` returns `D835`,`DC00` surrogate pair; `([char]::ConvertToUtf32('',0)).ToString("X")` returns codepoint `1D400` (more than 4 hexa digits). The `[char]` type has a static string method `ConvertFromUtf32(int utf32)` etc… – JosefZ May 30 '20 at 21:52

0 Answers0