Unicode special character not displaying in label

て烟熏妆下的殇ゞ 提交于 2021-01-27 05:19:11

问题


I would like to print that kind of character, but I dont get it, I thought c# supports unicode.

The way I solved it:

label3.Text = "\u1F6B5";

This is not the only symbol ,which does not work.

Thank you.


回答1:


  label3.Text = "\u1F6B5";

The \u escape takes only 4 hex digits, you are trying to use 5. So you end up with a string that contains two characters, '\u1F6B' and '5'. Looks like "Ὣ5", not what you want.

Using codepoints from the upper bit planes (codes >= 0x10000) require a capital U to get properly encoded into a string literal. Fix:

  label3.Text = "\U0001F6B5";

The machine also needs a font that contains the glyph. You'll know it is missing when you see a rectangle instead.




回答2:


I believe you also need to select a font that supports the unicode character for your label. Try something like Arial Unicode MS (or take a look at this guideline for fonts supporting that exact unicode character... e.g. the Segoe UI Symbol font).



来源:https://stackoverflow.com/questions/31690885/unicode-special-character-not-displaying-in-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!