8

C# doesn't want to put Unicode characters on buttons. If I put \u2129 in the Text attribute of the button, the button displays the \u2129, not the Unicode character, (example - I chose 2129 because I could see it in the font currently active on the machine).

I saw this question before, link text, but the question isn't really answered, just got around. I am working on applications which are going all over the world, and don't want to install all the fonts, more then "don't want", there are that many that I doubt the machine I am working on has sufficient disk space. Our overseas sales agents supply the Unicode character "numbers". Is there another way forward with this?

As an aside, (curiosity), why does it not work?

1
  • 2
    the question looks to be answered on that post.
    – David Fox
    Mar 24, 2010 at 11:00

4 Answers 4

14

The issue is:

  • C# will let you put Unicode in, like button1.Text = "Hello \u2129";, no problem
  • but the Visual Studio Forms designer will not recognize '\u2129' as anything special. By design.

So just paste in the '℩' in the Properties Window or use code.

3
  • 1
    @Frederik: the Unicode escape sequence '\u????' can be used in chars or strings, so it is not important that the char is concatenated to the string: it could just have easily been written button1.Text = "Hello\u2129".
    – Paul Ruane
    Mar 24, 2010 at 11:50
  • @Paul (and @Henk): true, didn't think that far. I'll remove my comment to avoid confusion Mar 24, 2010 at 12:00
  • Actually, Visual Studio Forms designer is escaping the \ character and parsing it as a regular \ (which in C# code would be "\\"). The designer supports Unicode properly so you're safe copy-pasting the string. Jan 9, 2015 at 14:43
2

Change the "Font" of the button to the "Font" (From google:Arial Unicode MS) which supports "u2129". It may help you

1

have you tried entering the characters manually? also, have you tried using a literal string with @"blahblahblah" ?

1

I was trying to include copyright symbol (\u00a9) in the form title. Using escape characters or changing fonts didn't work for me. I simply copy-pasted the symbol from text editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.