I have raw binary data received from device. I would like to display that data something like HEX editors do - display hex values, but also display corresponding characters.
I found fonts that have characters for ASCII codes 0 - 32, but I cannot get them to show on screen.
I tried this with WPF listbox, itemscontrol and textbox.
Is there some setting that can make this work?
Or maybe some WPF control that will show this characters?
Edit:
After some thinking and testing, only characters that make problems are line feed, form feed, carriage return, backspace, horizontal and vertical tab. As quick solution I decided to replace those characters with ASCII 16 (10HEX) character. I tested this with ASCII, UTF-8 and Unicode files and it works with those three formats.
Here is regex that I am using for this:
rawLine = Regex.Replace(inputLine, "[\t\n\r\f\b\v]", '\x0010'.ToString());
It replaces all occurrences of this 6 problematic characters with some boxy sign. It shows that this is not "regular printable" character and it works for me.
Not sure if that's excatly what you want, but I would recommend you to have a look in the #develop project. Their editor can display spaces, tabs and end-of-line markers.
I had a quick look at the source code and in the namespace ICSharpCode.AvalonEdit.Rendering
the SingleCharacterElementGenerator
class, seems to do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With