Whitespace character

From Wikipedia, the free encyclopedia
  (Redirected from Whitespace characters)
Jump to: navigation, search

In computer science, white space or whitespace is any character or series of characters that represents horizontal or vertical space in typography. 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 U+0020   space (HTML:  ), also ASCII 32, represents a blank space, used as a word divider in Western scripts.

The term "whitespace" is based on the resulting appearance on ordinary paper.

Contents

Definition and ambiguity

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 or enter key may be considered whitespace as well.

Unicode

In Unicode (Unicode Character Database) the following 26 characters are defined as whitespace character:

Whitespace[a] (Unicode character property WSpace=Y)
Code point Name Script General category Remark
U+0009 Common Other, control HT, Horizontal Tab
U+000A Common Other, control LF, Line feed
U+000B Common Other, control VT, Vertical Tab
U+000C Common Other, control FF, Form feed
U+000D Common Other, control CR, Carriage return
U+0020 space Common Separator, space
U+0085 Common Other, control NEL, Next line
U+00A0 no-break space Common Separator, space
U+1680 ogham space mark Ogham Separator, space
U+180E mongolian vowel separator Mongolian Separator, space
U+2000 en quad Common Separator, space
U+2001 em quad Common Separator, space
U+2002 en space Common Separator, space
U+2003 em space Common Separator, space
U+2004 three-per-em space Common Separator, space
U+2005 four-per-em space Common Separator, space
U+2006 six-per-em space Common Separator, space
U+2007 figure space Common Separator, space
U+2008 punctuation space Common Separator, space
U+2009 thin space Common Separator, space
U+200A hair space Common Separator, space
U+2028 line separator Common Separator, line
U+2029 paragraph separator Common Separator, paragraph
U+202F narrow no-break space Common Separator, space
U+205F medium mathematical space Common Separator, space
U+3000 ideographic space Common Separator, space
a. ^ Unicode 6.0, Chapter 4.6

Within the algorithm for Bidirectional writing, Unicode uses another definition of "Whitespace" (Bidirectional Character Type=WS). These Bidi-WS characters (18 out of the 26 listed in the table here) are "Neutral", they do not determine a writing direction, they just follow neighboring characters in this. The eight other characters listed here are also "Neutral", but have a different Bidi-type.

Usage

Computer languages

Runs of whitespace (beyond a first whitespace character) 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. And in the language called Whitespace, whitespaces are the only valid characters for programming, while any other characters are ignored.

Still, for most programming languages, abundant use of whitespace, especially trailing whitespace at the end of lines, is considered a nuisance.by whom? However correct use of whitespace can make the code easier to read and help group related logic. 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 that was committed by copying and pasting.

The C language defines whitespace to be "... space, horizontal tab, new-line, vertical tab, and form-feed".1 The HTTP network protocol requires different types of whitespace to be used in different parts of the protocol, such only the space character in the status line, CRLF at the end of a line, and "linear white space" in header values.2

Visible symbol

Sometimes the visible symbol ␣ (Unicode U+2423, decimal 9251, open box) is used to indicate a space. It is much like a closing square bracket ], although not as wide, rotated a quarter-turn clockwise and placed below the writing line. Some fonts render it too narrowly.

This symbol is used in a textbook on the Modula-2 computer language published ca. 1985 by Springer-Verlag, where it is necessary to explicitly indicate a space code. The symbol is also used in the keypad silkscreening of TI-8x series graphing calculators from Texas Instruments.3

File names

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 an underscore (_) as a word separator, as_in_this_phrase.

Another such symbol was U+2422 blank symbol. This was used in the early years of computer programming when writing on coding forms. Keypunch operators immediately recognized the symbol as an "explicit space".citation needed

See also

References

  1. ^ http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf Section 6.4, paragraph 3
  2. ^ R. Fielding et al., "2.2 Basic Rules", Hypertext Transfer Protocol—HTTP/1.1, RFC 2616 
  3. ^ Above the zero "0" or negative "(‒)" key

External links