Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you're truncating by character (or WHATEVER) counts, you are guaranteed to be doing it wrong - maybe not in your native language, but in somebody's.

Heck, even in one graphemically-straightforward language you can get silliness: http://www.images.generallyawesome2.com/photos/funny/photos/...



But truncation is very often needed when you have more text than space. What's the alternative?


If it's storage space, you truncate by bytes, rounding down to the nearest complete grapheme- no need to count graphemes. If it's display space, truncate by pixels, in which case you need "size in device units of the output text from a rendering engine". Again, no need to count graphemes.


Counting graphemes and detecting "the nearest complete grapheme" are basically the same problem.

The only reason counting graphemes is hard is because detecting grapheme boundaries is hard.


Of course, neither of those approaches solves the 'ass-' problem, which is possibly a red herring.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: