Need help?
<- Back

Comments (26)

  • Whitespace
    I was here before the first character was carved into stone and I will be here when the last photon is emitted.I'm also available via: @gmail.com(please don't write code with `@whitespace` as I get a lot of GitHub notifications)
  • pixelbeat__
    I think horizontal white spacing should be distinguished, as that's what most care about with splitting etc.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...
  • exacube
    If you want to learn how that magic multiplier value was derived, look up how to derive Perfect Hash Functions for a known set of values.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.
  • smallstepforman
    With bitmasks, if they just assumed bit 5 (whatever) as zero=whitespace, they would have saved billions of cpu cycles per device per day. With 32 bit unicode, that gives you 32 unique whitespace chars.Should have got guys that grew up with the 8-bit micros to write up a spec.
  • efilife
    This code is very simple but I still don't really get it. Why is the hashing needed and how is it faster than a regex? Can someone smarter than me explain?
  • LoganDark
    Whitespace depends on the context. For example, you could have characters that are not counted as whitespace in Unicode, but end up rendering as whitespace when displayed in a particular context. The only real way to check for this is to actually try to render it and see what happens. There are some other ways to approximate it, like checking the font that you use for rendering, or the bounds of the glyph, or other things like that, but the only way to really know for sure in all cases is to just render it and see what happens.
  • eviks
    > For instance, ZERO WIDTH SPACE (U+200B) isn't a whitespace character at all. Despite the name, it's a format character that can indicate a word or line break opportunity without adding a visible gap.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 evolvingunfortunatly the evolution is freezing, so such issues remain unfixed. Here is a few emojis as a consolation prize instead!
  • adornKey
    With font.color = white even an ordinary "W" could count as whitespace... Something to remember if you see whitespace with an extraordinary width out there in the wild...
  • austin-cheney
    The \s character class in JavaScript regular expressions includes 25 characters. I don’t know if that perfectly matches the Unicode list of 25 characters, but it does make identifying white space simplistic.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.
  • srgb_vs_cmyk
    [dead]
  • finn888
    [flagged]
  • novalyn_ai
    [flagged]