What is Whitespace?
Whitespace refers to invisible characters of text, such as the space character, the tab character, carriage return characters, and new line characters. The latter three are represented by the text codes \t
, \r
, and \n
, respectively.
Whitespace is typically "trimmed" or "stripped" when handling user input, because they're often typed by accident. For example, if a field asks you to type your name, there is just no way that your name starts with a space. Or ends with it. I mean, nowadays people have some pretty weird names, and some people on this planet do not have personal names, or have multiple names, but in any case the average person does NOT have a significant space at the start or end of their name, so it's probably safe to ignore it. I assume. This is probably one of those things that can become a lawsuit one day.
Observations
Historical Context: you may be wondering why is whitespace called whitespace when every programmer on the Internet appears unable to an IDE that doesn't have a dark theme in it. Shouldn't it be blackspace, then? Well, that's because in the past IDEs didn't have dark themes, so the background color was actually white back then!
Leave a Reply