Using Unicode Characters in C # Controls

I want to add the Greek letter omega (U + 03A9) to the label that I posted on the form. I already turned on the encoding of the form, but how to set the contents of the label so that omega appears, and not UTF char code.

So, take this XAML

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

I want U + 03A9 to be converted to omega

in the code behind I believe that I can do something like

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

But I wonder if I can do this in XAML

+4
source share
2 answers

Just add the letter symbol Ω as your control text. No additional modification is required.

 lblOmega.Text = "Ω"; 
+4
source

It's not entirely clear what you mean (how did you switch 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); } } 
+5
source

Source: https://habr.com/ru/post/1299441/


All Articles