简体   繁体   中英

Some unicode characters not showing in textbox c# wpf

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.

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: &#x2407;"/>

with this result:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM