- Whitespace (computer science)
In
computer science , whitespace is any single character or series of characters that represents horizontal or vertical space intypography . When rendered, a whitespace character does not correspond to a visual mark, but typically does occupy an area on a page. For example, the common whitespacesymbol " " (theUnicode character at the 32ndcode point ) represents a blank space, as used between words and sentences in Western scripts.The term whitespace is based on the assumption that the background color used for rendered text is white, and is thus confusing if it is not.
As is common in technical literature, the two words "white space" have found widespread usage as the single term "whitespace", especially when used as an
adjective , as in "whitespace character". Some specifications refer to "white space" while others refer to "whitespace"; there is no difference between the terms, although exactly which characters are being referred to does vary from context to context. For example, inHTML , "whitespace" includes theform feed character, while in XML, "white space" does not.The most common whitespace characters may be typed via the
space bar or theTab key . Depending on context, a line-break generated by theReturn key (Enter key ) may be considered whitespace as well.Runs of whitespace occurring within
source code written in computerprogramming language s are generally ignored; such languages are "free-form". But, for example, in Haskell and Python, whitespace and indentation are used for syntactical purposes. In many programming languages, abundant use of whitespace, especially "trailing whitespace" at the end of lines, is considered a nuisance. Ininterpreted language s, parsing of unnecessary whitespace may affect the speed of execution. Inmarkup language s likeHTML , unnecessary whitespace increases the file size, and may so affect the speed of transfer over a network. On the other hand, unnecessary whitespace can also inconspicuously mark code, similar to, but less obvious than comments in code. This can be desirable to prove aninfringement of license or copyright that was committed by copying and pasting.The C language defines whitespace to be "... space, horizontal tab, new-line, vertical tab, and form-feed". The
HTTP network protocol has very strict requirements about what type of whitespace can occur in the control structures (such as the header fields) and where it must and must not occur.On some occasions, such as a textbook on the Modula-2 computer language published ca. 1985 by Springer-Verlag, it is necessary to explicitly show a symbol to indicate a space code. That book, at least, used the symbol ␣ (Unicode U+2423, decimal 9251, OPEN BOX) to show an explicit space code. (In case it doesn't render well on a monitor screen, it's like a ] (closing square bracket) rotated a quarter-turn clockwise, although not as wide, and placed below the writing line. Some fonts render it too narrowly.)
Such usage is similar to multiword file names written for operating systems and applications that are confused by embedded space codes—such file names instead use a low line (_) as a word separator, as_in_this_phrase.
Another such symbol was ␢ (Unicode U+2422, decimal 9250, LATIN SMALL B WITH STROKE). This was used in the early years of computer programming (especially by IBM?) when writing on coding forms. Keypunch operators immediately recognized the symbol as an "explicit space".
Unicode
In
Unicode (Unicode Character Database) the following codepoints are defined as whitespace:
*U0009-U000D (Control characters, containing TAB, CR and LF)
*U0020 SPACE
*U0085 NEL
*U00A0 NBSP
*U1680 OGHAM SPACE MARK
*U180E MONGOLIAN VOWEL SEPARATOR
*U2000-U200A (different sorts of spaces)
*U2028 LSP
*U2029 PSP
*U202F NARROW NBSP
*U205F MEDIUM MATHEMATICAL SPACE
*U3000 IDEOGRAPHIC SPACESee also
*
Programming style
*Indent style
*Space (punctuation)
*Trim (programming) External links
[http://unicode.org/Public/UNIDATA/PropList.txt Propertylist of Unicode Character Database]
Wikimedia Foundation. 2010.