3 ms·
I'm glad my near-exact pain has been experienced by others. I had an undefined function call of ' ' in a ruby script years ago. Finally, I turned to a hex edito
by sethammons 7y ago
I'm glad my near-exact pain has been experienced by others. I had an undefined function call of ' ' in a ruby script years ago. Finally, I turned to a hex editor at the suggestion of a colleague. The culprit was non-ascii whitespace that ruby decided should be a function declaration. Copy pasta error out of a hipchat code snippet.
- Dumblydorr 7y agoSorry, 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
- davestephens 7y agoPasta and computers are always a bad mix...
- mark-r 7y agoEspecially spaghetti code...