Reputation: 73
Alright, so I am quite new to C# programming and i've stumbled across the following problem. I need my program to return a character based on the hex value i send. For example if I type 6E it should return 'n'. This works fine, however when i type 07, which should return a Bell symbol it shows nothing in my textbox. In the console it shows up fine. The same problem occurs with other symbols as well.
I've tried using another font, I use Arial now but that doesn't seem to work. Tried unicode encoding. Tried a richtextbox. I also tried to hard code the bell symbol, "/u0007" if im correct and then it also will not show up in my textbox.
It all end up with the same result, console shows the symbol but textbox will not. It also doesn't return a square, which it would when the font wouldn't recognize the character. But simply nothing, it skips the character and doesnt output it.
I'm not really sure in what direction to look at this point and any help would be appreciated.
Upvotes: 0
Views: 1566
Reputation: 43
In the case of string binding and string operations, I found that this conversion helps it to recognize the Unicode char, the given example converts U+274C to string
string xChar = Char.ConvertFromUtf32(0x274C);
Read more from MS docs - Char.ConvertFromUtf32(int utf32)
Upvotes: 0
Reputation: 1052
Do you mean this Bell: https://www.fileformat.info/info/unicode/char/0007/browsertest.htm? Then it won't show anything, because it is a control code...
If you've meant the bell character itself, then it has a different unicode: U+2407. So, to show this in a TextBox in XAML you write this code:
<TextBox Width="200" Height="50" Text="This is an unicode character: ␇"/>
with this result:
Upvotes: 3