There is a Char.IsControl() method to identify such characters, but I want a way to convert them to "normal" characters.
i.e. some way to visualise a string that contains such characters. Probably similar to what Notepad++ does.
Obviously such a visualisation will be imperfect, and ambiguous ... but does it exist as a built in method?
Notepad++ is converting the control characters to the control pictures U+240x and you'll also have to do that yourself. To convert
controlCharto its visualization just usecontrolChar + 0x2400orcontrolChar + '\u2400'Demo on dotnetfiddle. Output:
You can also do like this
Of course this only works for the first 32 control characters (and space), to convert the remaining ones you have to use a
Dictionaryor something similar because the code points aren't contiguous. For example 0x7F will need to be converted to ␡ (U+2421). There aren't any control pictures for the C1 control codes so you're out of luck for those. There are many other control codes above U+0080 and most of them don't have a control picture either