Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

One can look up Unicode Characters with Regular Expressions. On Jan Goyvaerts website I found a RegExp whose meaning I don't understand :

\p{Zs} or \p{Space_Separator}: a whitespace character that is invisible, but does take up space

So I wonder if I got this right: a Whitespace Character

  • is the 'empty' space between two words, columns, lines, whatever
  • it's 'invisible' in so far as it contains nothing than the blank paper ⁄ screen
  • it 'takes up space' in so far as the place taken through it can't be occupied through a letter, symbol, anything comparable

According to this I came to the following questions:

  • are there 'visible whitespace characters'
  • could a whitespace character 'take no space up'

This would be quite the opposite of what is defined. Both make perfectly sense, but then both could describe the same, depending on the point of view: an empty space is visible through the absence of anything displayed there except the blank paper ⁄ screen but then it is invisible as there is nothing to see. At this point I sense a border with Philosophy: How does one measure the amount of Nothingness than through it's counterpart, or so.

share|improve this question
2  
Well, if a whitespace character takes up space, it's visible, otherwiseitwouldlooklikethis. And yes, there are such characters that do not take up space. Sometimes the whitespace is even part of another character, for example the Japanese dot 。 has whitespace in it as Japanese don't really ever use spaces as is. Also a list on Wikipedia en.wikipedia.org/wiki/Whitespace_character –  frostschutz Apr 13 '13 at 15:22

2 Answers 2

up vote 0 down vote accepted

Some classic ASCII invisible whitespace characters are:

  • Tab : \t
  • New line: \n
  • Carriage return : \r
  • Form feed : \f
  • Vertical tab: \v

All of these are treated as characters by the computer and displayed as whitespace to a human.

Other invisible characters include

  • Audible bell : \a
  • Backspace : \b

As well as the long list in the wikipedia article given by frostschutz.

share|improve this answer

From the PCRE source testsuite:

/^\p{Zs}/8
    \ \
    \x{a0}
    \x{1680}
    \x{180e}
    \x{2000}
    \x{2001}

So... at the very least it includes space, nobreak-space, ogham space mark, mongolian vowel separator, en quad, em quad?

The meaning of \p{Zs} according to Python 3 using regex https://pypi.python.org/pypi/regex (standard Python re does not understand \p{Zs}:

$ python3
Python 3.2.3 (default, Mar 23 2013, 23:30:23) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import regex
>>> import sys
>>> allofunicode=''.join([c for c in map(chr, range(sys.maxunicode+1))])
>>> regex.findall(r'\p{Zs}', allofunicode)
[' ', '\xa0', '\u1680', '\u180e', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u202f', '\u205f', '\u3000']

(sorry for the weird code - I'd do it in Perl but my Perl is rusty :P)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.