使用 int 将 Astral Plane Unicode 代码点打印到控制台

发布于 2024-08-04 22:26:58 字数 447 浏览 1 评论 0原文

请参阅此处的相关问题

但是,char 会转到 0xffff(或 65535)。我需要编写 0xd800df46 (或 66374),哥特式字母 Faihu,因此将 int 转换为 char 不会工作。我完成了转换,也就是说,我得到了正确的整数,这意味着我计算了代理对,但我不知道如何“渲染”它,将其转换为要作为字形输出的字符。

请注意,我不能使用 \Unnnn ......好吧,理论上的原因。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春花秋月 2024-08-11 22:26:58

好的,您需要将单个整数转换为表示为字符串的代理对

string x = char.ConvertFromUtf32(66374);

对于更多操作,您可以在<中使用我的Utf32String类a href="http://pobox.com/~skeet/csharp/miscutil" rel="nofollow noreferrer">MiscUtil,以及 System.Char 中的各种其他方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文