This question already has answers here:
WPF Font: Why are some characters missing?
(5 answers)
Closed 3 years ago.
I am trying to set the Text property of a textbox in WPF with a string containing umlaut characters:
Textbox.Text = "!##$%&*,ÖÄäü";
But the textbox only displays !##$%&*, and omits the umlaut characters.
How to make the umlaut characters to appear?
You could try to save the file with the Unicode (UTF-8 with signature) - Codepage 65001 encoding (File->Save As->Save with Encoding in Visual Studio) or look up the unicode for the character in the Character Map application in Windows.
For ü, it's 00FC for example:
Textbox.Text = "\u00FC";
Related
I want to display and edit serial data (e.g. NULL, STX, ETX, ENQ, etc. characters) in the text box in WPF. It should be displayed same like Notepad++ as shown here.
I have tried using textbox, RichTextBox in WPF, but only printable characters are shown. Non printable characters (e.g. NULL, STX, ETX, ENQ, etc. characters) are not shown.
Will you please guide me how can I display this?
I am trying to render Arabic text in WPF at Glyph level, on a character-by-character basis. Rendering Latin text was easy, each character simply translates to a Unicode codepoint and I used GlyphTypeface's CharacterToGlyphMap dictionary to retrieve a GlyphRun for each character.
With Arabic (and other languages) it seems that things are a lot more complicated: characters use different glyphs depending on the characters that surround them and on their position in a word. I suppose these contextual character forms all have their own Unicode codepoints too.
My questions are:
- How would I get these context-dependendent codepoints? A TextBlock displays Arabic text correctly (I suppose), how does it know which glyphs to use?
- Would that character-after-character approach even work for Arabic or is there more that I should know?
I have some Korean text I need to display on my WinForm. The text displays fine in my ListBox control. The same text does not display in my DropDownList control. Both controls have a font of Arial 8pt. The ItemHeight property for both controls is 14. I can't spot any differences in the properties of these controls that would mean one control displays the text correctly and the other doesn't.
I have read in the following article that the problem is either caused by the font or the character encoding.
From what I can gather, the code uses standard .NET strings. There are no character conversions taking place. The required font to display Korean must be installed, otherwise I would not be able to view it in one control and not another. What am I doing wrong?
I resolved this by changing the font from Arial 8pt to Arial Unicode MS 8.25pt. As Luis Quijada pointed out when he suggested I look at this question
ComboBox with Segoe UI and Japanese text
Changing the font from Arial to Arial Unicode MS was an acceptable workaround for me. I'm not sure which languages Arial is supposed to support. It's possibly a Microsoft bug that Arial works in the ListBox but not in the DropDownList for the Korean text.
I am using this sequence: Alt+27 (using the numeric keypad) in order to enter the 'Esc' character in a Winforms TextBox. Then I attempt to read back the textbox string using the Text property. I was expecting the first character to be 'Esc' (integer value 27) but instead I found that the integer value of 8592. What is going on? How can I read back correctly the 'Esc' character?
Alt-27 is a shortcut for ← which is indeed Unicode character 8592 - see http://www.alt-codes.net/ for the full list.
The width of Tab (\t) character in silverlight TextBox is not equal to 4 spaces or 8 spaces. It's too short.
Is it possible to change the width of the TAB (\t) character displayed in a silverlight TextBox?
Note that I want to avoid replacing TABs with spaces.
Any ideas on how to do this?
Silverlight does not allow you to change the tab character length in a TextBox.
If your reading in a string (from a file or something) and setting the Text to it then if you look at your Text Property you'll see the escaped tab (\t). Searching for a \t is easy
TabTextBox.Text = TabTextBox.Text.Replace("\t", " ");
So this will replace all tabs with 4 spaces.
Besides pressing tab in a TextBox will not tab the text. It will focus to the next UIElement within the parent UIElement.
Or maybe on tab key press event, append the string literal to the text box. Similar to what MyK is suggesting.
If you're trying to get this to display, write a converter. the syntax is around--just grab an example, gut it, rename to something like 'tabstoptexttospacedtextconverter', add a reference to your local controls in app.xaml, then create an instance of it and give it an x:name to use it. Bind the data for your text box and assign it your new converter.
It'll be a little bit of hassle because you'll have to determine the appropriate width of the final display TB, and then probably use a converterparameter to make that work. But long story short, split on \t, then foreach(string str in splitSourceText) do something like this:
for (int i = 0; i < (str.Length % 8 > 0 ? str.Length % 8 : 8); i++) str+= " ";
You can limit the characters on the split string arrays with the parameter or split on \r\n first.