News for hackers. Stuff that matters.
Re:It's Not Wrong that " ".length == 7 by crazygringo on Saturday August 23, 2025 @11:19AM (#44996603)
Practically speaking, for maximum lengths, you generally want to limit code points or bytes, not characters. You don't want to allow some ZALGO monstrosity that is 5 characters but 500 bytes.

For exact lengths, you often have a restricted character set (like for phone numbers) and can validate both characters and length with a regex. Or the length in bytes works for 0–9.

Unless you're involved in text layout, you actually usually don't wind up needing the exact length in characters of arbitrary UTF-8 text.

There are no comments on this comment yet.