Reputation: 91
I want to print a Unicode character with 5 hexadecimal digits on the screen (for example to write it on a Windows Forms button).
For example, the Unicode of the character Ace Heart is 1F0B1. I tried it with \x
but it can present up to 4 digits.
Upvotes: 4
Views: 3069
Reputation: 1500385
You can use the \U
escape sequence:
string text = "Ace of hearts: \U0001f0b1";
Of course, you'll have to be using a font which supports that character...
As an aside, I'd strongly recommend avoiding the \x
escape sequence, as they're hard to read. For example:
string good = "Bell: \x7Good compiler";
string bad = "Bell: \x7Bad compiler";
When presented together, at first glance it would seem that these are both "Bell: " followed by U+0007 followed by either "Good compiler" or "Bad" compiler... but because "Bad" is entirely composed of valid hex characters, the second string is actually "Bell: " followed by U+7BAD followed by " compiler".
Upvotes: 12