Printing Astral Plane Unicode code point to console using int
-
07-07-2019 - |
Question
Please see here for a related question.
However, char
goes to 0xffff
(or 65535
). I need to write 0xd800df46
(or 66374
), Gothic letter Faihu, so casting that int
to char
will not work. I do the conversion ok, that is, I get the correct integer, meaning I calculate the surrogate pairs ok, but I don't know how to "render" it, convert it to a character to be output as a glyph.
Please notice that I cannot use \Unnnn for ... well, theoretical reasons.
Thank you.
Solution
Okay, you need to convert a single integer into a surrogate pair which you'd represent as a string:
string x = char.ConvertFromUtf32(66374);
For more operations than that, you can use my Utf32String
class in MiscUtil, as well as various other methods in System.Char
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow