tags:

views:

278

answers:

2

I want to add the Greek letter omega (U+03A9) to a label I've placed on the form. I've already switched the encoding of the form, but how do I set the content of the label such that an omega appears and not UTF char code.

So taking this XAML

<Label Height="25">U+03A9</Label>

I want the U+03A9 to be converted to an omega

in the code behind I believe I can do something like

targetEncoding = Encoding.getEncoding(utfEncoding);
lblOmega.Content = targetEncoding.getBytes("\u03A9");

But I'm wondering if I can do this strickly in the XAML

+2  A: 

It's not really clear what you mean (in what way have you switched the encoding of the form?) but this works fine for me:

using System;
using System.Windows.Forms;

class Test
{
    static void Main()
    {
        Form form = new Form
        {
            Controls =
            {
                new Label
                {
                    Text = "-> \u03a9 <-"
                }
            }
        };
        Application.Run(form);
    }
}
Jon Skeet
+2  A: 

Simply add the literal symbol Ω as the control's text. No futher modification necessary.

lblOmega.Text = "Ω";
George
So obvious I didn't even think about that. Ended up just coping and pasting the character directly into the XAML. Thanks.
Scott
XAML is XML. XML can talk Unicode. Isn't that nice? ;-)
Joachim Sauer