1

I am displaying values as roman numbers, when printing to console it worked fine. However Using windows forms the richtextbox will not display duplicate codepoints.

I tried changing the font, is there some encoding part to richtextbox I am missing?

I am building the string using stringbuilder, as you can see in the pictures below the string variable does actually contain the characters. Both examples are using value 20 and displaying it with 2 codepoints next to the value 10. These are appended at once using stringbuilder before displayed.

Here the program calls the string and displays it correctly:

Console variable

console output

Here is the richtextbox but it fails to display:

rbox

outputbox

These are the codepoints I am appending using stringbuilder: enter image description here

GreatGaja
  • 315
  • 2
  • 11
  • Use `Segoe UI`, `Microsoft YaHei UI` or similar font. Test with just `displayBox.Text = "\u2169\u2169";` – Jimi May 25 '20 at 11:23
  • Some notes on Font Fallback [here](https://stackoverflow.com/a/51612395/7444103) – Jimi May 25 '20 at 11:43
  • I managed to get a consistent output outside of terminal normalizing the string product of string builder to formKC. Went for C because I am using overline for numerals above 1000. this ensure displaying it as one "character". I tried the suggested fonts and also some known unicode fonts like Lucida. Nothing seemed to help. thanks for the links good reads, I noticed it went over how it defaults using HKLM in windows. Atm I am using mono on linux, so no idea were it would come from. Might to a better write up below once I know exactly what happened. – GreatGaja May 25 '20 at 20:08

1 Answers1

0

The form was not outputting a given string as XTerm(the terminal used in successful examples). As Jimi mentioned some fonts might not display codepoints properly. The issue here however is that XTerm was handling codepoints differently than windows forms.

The way to display and/or compare a string that uses diacritics or a other combination of codepoints is using normalize on it. In this case I was returning a string from stringbuilder made by appending codepoints. Those were getting malformed or misread the moment the string entered the richTextBox.

Using normalize form KC solved this. The reason I chose KC over KD is because KC will display a character with diacritics as a single "character", this is important since I was using overline for values above 1000.

for more info on normalize see Unicode Annex#15

GreatGaja
  • 315
  • 2
  • 11
  • So, did you set the RichTextBox.Text with something like `displayBox.Text = new StringBuilder("\u2169\u0305").ToString().Normalize(NormalizationForm.FormKC);`? An example would be more interesting, maybe with a comparison of the results in Windows and Mono/Linux. – Jimi May 26 '20 at 00:42
  • Wanted to supply the comparison today, but my windows machine is stuck in a boot loop atm and kind of swamped. Will add to this over the weekend. it will provide better insight on the problem/answer I agree. – GreatGaja May 28 '20 at 13:00