4 ms·
When you have fixed width font and need to size columns appropriately for the data displayed in eg: a table.
by yrral 5y ago
When you have fixed width font and need to size columns appropriately for the data displayed in eg: a table.
- lofties 5y agoOh that's a great one! I have a thermal receipt printer (can recommend anyone to buy one, they're amazing) that is 80 characters wide. Would definitely screw up the formatting if it ever encountered this situation. (and no further validation was performed on the uppercase'd string)
- BlueTemplar 5y agoThose clacking mechanical train/plane schedule displays came to mind, though I assume they are only rarely used these days ?
- sillysaurusx 5y agoI guess I'll admit that fixed width fonts are a valid use case, but I'd argue that that defeats the point of displaying language to humans. There are so many cases this doesn't apply: RTL languages, kanji, pretty much anything that's not eurocentric. My original response was going to be that you don't actually care about "foo".length in that context, either. You care whether one string is larger than the other, i.e. the actual value doesn't matter -- all that matters is that if a string X is longer than string Y, then the length should increase. But mathematically, that's just a precise definition of requiring the string length, so that logic doesn't work out. If you email me your paypal/venmo/whatever, you can collect the $20, since you were the first to point out monospaced font. I still feel that monospaced fonts are sidestepping the whole point, but I won't be pedantic about it. (https://news.ycombinator.com/item?id=29303325 https://news.ycombinator.com/item?id=29303325 points out why this isn't a sensible operation, if you were curious about why I feel inclined not to concede the bet.)
- yrral 5y agoIf you feel inclined, feel free to donate the $20 to a charity of your choice. Thanks! Just for more context, I was thinking data tables: like this. https://images.app.goo.gl/wWJgx9sntUAhXzQ66 https://images.app.goo.gl/wWJgx9sntUAhXzQ66
- sillysaurusx 5y agoActually, I've been meaning to ask: what's a good charity to donate to? I haven't had much money until recently, so I've never sat down and figured out a charity. There are lots to choose from, and I suppose I don't really care about making a perfect choice. I'm mostly just curious what other people donate to. Re: the data tables, it's tempting to think that you need the string length for that case. But what you really care about is whether the strings start at the same place, and whether the string fits in a column -- both of which are questions best answered by a font subsystem rather than relying on string length. But the data table case is so common that I agree it fulfills the terms of the bet, in the strictest sense. But e.g. that Competition / Name column will break for various non-English languages if you try to base the formatting on "number of visible characters."
- latch 5y agoFYI, depending on where you live, charitable donations can have tax-benefits (i.e. in the form of a deduction). It can be worth making sure you're donating to charities which are enrolled in such programs. For example, Singapore has a 250% tax deductions on donations (this is pretty extreme though, I'd bet there are very few countries with > 100%). I think you'd find most people donate based on what's touched their lives, e.g. breast cancer research if you lost a loved on to breast cancer. If you believe climate change is the existential crisis, then that's a good avenue to explore. e.g., https://www.rainforestcoalition.org/ https://www.rainforestcoalition.org/
- sillysaurusx 5y agoThank you for the tips! I really appreciate it. I ended up donating $200 to this kid who lost his finger and then got a staph infection: https://watsi.org/profile/08a347b3594d-savy https://watsi.org/profile/08a347b3594d-savy And then fulfilled the bet by donating $20 to Watsi.
- deathanatos 5y agoWidth of text is a discreet thing from string "length"… or, well, string "length" is particularly vague. But lets presume the OP meant length in unicode code points or grapheme clusters. (Neither of these will be width under a fixed width font. There's also length in bytes, which ofc. is also not width in a fixed width font.) E.g., most Asian characters & emoji are 2 cell widths in a fixed with font for a single character. The character "e" is 1 byte in UTF-8, "é" is >1. The "family of four" emoji can be up to 11 code points, 41 bytes (in utf-8), and 2 cell widths (still just an emoji) and is, I presume, a single grapheme cluster.