Displaying a unicode character

G

Guest

Hi,
I'm just trying to do something very simple, but I can't find a simple
example. In a TextBox and Button on a WinForm, I just want to display some
Unicode characters -- specifically, U+2660, U+2663, U+2665 and U+2666 (the
playing card symbols).

It's my understanding that all strings is .NET are unicode strings. Is that
correct?

Currently I have the unicode characters as input to some strings:
E.g.

string s = "♠♣♥♦"; // weird, this text box doesn't recognize the diamond
symbol

Then, I simply want to display those characters in a textbox:

textBox1.AppendText(s);

So, what other steps along the way do I need to do?

Thanks,
 
J

Jon Skeet [C# MVP]

Quimbly said:
I'm just trying to do something very simple, but I can't find a simple
example. In a TextBox and Button on a WinForm, I just want to display some
Unicode characters -- specifically, U+2660, U+2663, U+2665 and U+2666 (the
playing card symbols).

It's my understanding that all strings is .NET are unicode strings. Is that
correct?

Currently I have the unicode characters as input to some strings:
E.g.

string s = "????"; // weird, this text box doesn't recognize the diamond
symbol

Then, I simply want to display those characters in a textbox:

textBox1.AppendText(s);

So, what other steps along the way do I need to do?

Set the font to one which supports those symbols. You might want to use
CharMap to work that out.
 
M

Mihai N.

string s = "♠♣♥♦";
Try string s = "\u2660\u2663\u2665\u2666";
The strings are Unicode, but your source file is not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top