3 ms·
Sorry, beginner here, can you explain more simply the difference in the whitespaces? Are they just encoded differently?
by Dumblydorr 7y ago
Sorry, beginner here, can you explain more simply the difference in the whitespaces? Are they just encoded differently?
- sethammons 7y agoThere are full on character encoding introductions. I think an easy to approach one is: https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/ https://www.joelonsoftware.com/2003/10/08/the-absolute-minim... Basically, ascii is encoded as integers. '32' represents a space. However, ascii is quite limited and if you want non-US-centric characters, you need to use other character sets. For a myriad of reasons, once you go into unicode (the Universal Character Set) there are lots more options for characters. For example, there are multiple whitespace characters. http://jkorpela.fi/chars/spaces.html http://jkorpela.fi/chars/spaces.html These exist to give different widths or other adjustments to text that is non-ascii. What likely happened in the post (and what did happen to me) is copy-pasting from some document that changed a normal ascii space (that Ruby would expect and know how to deal with) into a unicode character that Ruby interprets as any other character. It would be like having a stray 'g' in the line, but you, as a developer, don't see it. Fun :)
- schoen 7y agoThis explanation of where the non-breaking space came from feels really likely: https://news.ycombinator.com/item?id=21290159 https://news.ycombinator.com/item?id=21290159