Hacker News
How hard is it to check for whitespace?
exacube
|next
[-]
I'm not sure which method was used for this specific set of values, but from googling it's seen advances in the past decade.
Whitespace
|next
|previous
[-]
I'm also available via: @gmail.com
(please don't write code with `@whitespace` as I get a lot of GitHub notifications)
pixelbeat__
|next
|previous
[-]
Have a look at how GNU coreutils classifies each type of spacing (in a cross platform consistent way) at https://github.com/coreutils/coreutils/blob/master/src%2Fsys...
smallstepforman
|next
|previous
[-]
Should have got guys that grew up with the 8-bit micros to write up a spec.
mananaysiempre
|root
|parent
|next
[-]
The problem was, they had to sell their invention to other guys that had grown up with 8-bit micros and in the meantime had gotten very attached to their specific 8-bit encodings, so they had to make a lot of compromises: first 128 characters match ASCII; first 256 characters match Latin-1; alphabets encoded in order; codepoint-to-codepoint transcoding from any (reasonable) legacy encoding; throw out enough stuff to not need more than 2^16 characters. They were also racing against time, because in the meanwhile ISO was cooking up 10646, the Universal Character Set, built around ISO 2022’s teletype-inspired architecture of charset switching, and that only got killed because software vendors essentially declared a boycott and pointed to Unicode instead.
The result came out rather awkward as well as fairly expensive, and a lot of the promises needed to be broken afterwards anyway. But they’d have no users had they had done things differently. (Meanwhile, the UCS as initially conceived lacked such advanced operations as string equality.)
efilife
|next
|previous
[-]
usrnm
|root
|parent
|next
[-]
lelanthran
|root
|parent
|next
|previous
[-]
It's a perfect hash (i.e. no collisions) that hash to an entry in a 32-element array.
Very similar to how we usually do quick lookups of strings for `switch()` statements: https://github.com/lelanthran/libxtree/blob/878cb4fc11ffd617...
SerCe
|root
|parent
|next
|previous
[-]
LoganDark
|next
|previous
[-]
tjoff
|root
|parent
|next
[-]
What turns into whitespace due to rendering? Just because my font lacks that symbol doesn't mean it is whitespace.
LoganDark
|root
|parent
[-]
tjoff
|root
|parent
[-]
LoganDark
|root
|parent
[-]
eviks
|next
|previous
[-]
that's what happens when you throw a lot of garbage in, mix it up and forget to clean (piece of trivia - this was a space char many years ago; another one - the Braille whitespace char is unitechnically not whitespace)
> So even the assumption that whitespace must look empty isn't always true.
indeed, another obvious fail of this classification ("naming is hard")
> not frozen in time, and is constantly evolving
unfortunatly the evolution is freezing, so such issues remain unfixed. Here is a few emojis as a consolation prize instead!
adornKey
|next
|previous
[-]
austin-cheney
|next
|previous
[-]
White space characters are challenging to differentiate in human readable text, but JavaScript makes that perfectly clear to humans by splitting a string on every character, which is helpful for debugging.