Show space characters in standard edition

Displaying whitespace in Eclipse is a simple trick , but unfortunately this only applies to editor views.

enter image description here

Is there a way to display these characters in the console view? I would find it useful to verify that the string formatting is correct. Any help?

+4
source share
2 answers

Since there was a bit of confusion regarding the term โ€œwhitespace,โ€ I will try to cover both possible instances.

If you want to display things like newlines and tabs, Java strings contain special characters for these constructs. \n display a new line (line break). \t display the tab. \r - carriage return. There are others as shown in the table here , but they are most common.

Alternatively, if you plan to display spaces as a visible character, this is a completely different problem. In this situation, I assume that you want to display the tab as an arrow or a space between words as a dot, as some text editors do. As far as I know, there are no built-in features for this.

However, you could replace the existing spaces with the unicode character that you want to represent as a space. The Java String class supports the use of Unicode characters; you just need to find the one you want to use to indicate, say, a tab, and then replace all instances of \t with this character.

0
source

http://www.cafeaulait.org/course/week2/04.html

In short: you can use \ r, \ t, \ f and \ n in the console text editor for the necessary spaces. \ t = Tab, \ n = New line, etc. See the link for more details.

0
source

All Articles