showing invisible characters in textarea


I am trying to retrieve database rows into a Listbox, and when I select one row, if it includes any Carriage Return/LineFeed/trailing Space then I would like to show those characters in Textarea with other characters such as CR,LF,TS and so on.

I am not sure how I can detect those characters and replace it with other characters in Textarea.
Can you give me some ideas?

sure you can find and replace them… just like any other character… but if you put a printable character in its place, you lose the functionality (ie… no more linebreak)… And if you replace the endofline with a printable character AND endofline to maintain the functionality, then the user can simply edit them out, or add stuff afterthem.

CustomEditField is able to display invisible characters (among many other features). 32 bit only though.

JUST FYI since its not based on text input canvas there cocoa functionality that you cant ever get to work right using a canvas subclass
Proper Cocoa Keyboard handling is one
Its why we even created the text input canvas in the first place

What you can do, is replace the invisible character by a pair : a marker that will visualize it, plus the invisible character. For instance,

EndofLine will be replaced by &U00B6+EndOfLine, which will show as ¶

Same thing for tab, and so on. In Word, the space is also replaced by middot : &u00B7.

To revert, remove the markers, and replace middot by space.

Of course, such a technique will throw off text len. But it is the simplest.

and present them in some sort of grey to make a difference between the “invisible” character and a standard character.

Thank you everyone.
I found it in CustomEditField project.

Other inputs are really helpful for understanding. Thanks again.