Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicode special character not displaying in label

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.

like image 439
user254197 Avatar asked Jul 29 '15 03:07

user254197


2 Answers

  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.

like image 198
Hans Passant Avatar answered Sep 18 '22 07:09

Hans Passant


I had this issue today to struggle with. I found CompatibleTextRendering property has an affect if Unicode symbols are displayed or not.

See image here how it affects Label and LinkLabel controls.

I solved it using Segoe UI Emoji font.

like image 31
Remigijus Pankevičius Avatar answered Sep 20 '22 07:09

Remigijus Pankevičius