Whitespace (computer science)

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computer science, white space, whitespace, or a whitespace character is any single character which represents horizontal or vertical space in typography, or is a series of such characters.

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 whitespace symbol " " (the Unicode character at the 32nd code point) represents a blank space, as used between words and sentences in Western scripts.

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, in HTML, "whitespace" includes the form feed character, while in XML, "white space" does not.

The most common whitespace characters may be typed via the space bar or the Tab key. Depending on context, a line-break generated by the Return key (Enter key) may be considered whitespace as well.

Runs of whitespace occurring within source code written in computer programming languages 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. In interpreted languages, parsing of unnecessary whitespace may affect the speed of execution. In markup languages like HTML, 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 an infringement of license or copyright, which 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.

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.

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. As the Wikipedia article on the interpunct points out, many different characters (in computer-readable form) create white space.

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".

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 SPACE

Propertylist of Unicode Character Database

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.