|
|
|
|
|
by zbentley
2816 days ago
|
|
Sorry, visual length as in visual number of "character-equivalent for purposes of word length" things. Those things are close to, but not exactly the same as, grapheme clusters, so the latter can often be used as an imperfect (but much more useful than unicode points or bytes) proxy for the former. There's no perfect representation of number-of-character-equivalents that doesn't require understanding of the language being handled (and it's meaningless in some languages as I said), but there are many written languages in which knowing the length in those terms is both extremely useful and extremely hard to do without grapheme cluster identification. |
|
Serious question: why would you want to do this?
I know it's fashionable to limit usernames to X characters... but why? The main reason I've seen has been to limit the rendered length so there are some mostly-reliable UI patterns that don't need to worry about overflows or multiple lines. At least until someone names themselves:
W W W W W W W W W W W W W W W W W W W W
Which is 20 characters, no spaces, and will break loads of things.
(I'm intentionally ignoring "db column size" because that depends on your encoding, so it's unrelated to graphemes)