4 ms·
Is there ever a genuine, non-arbitrary business requirement to limit any string to a certain number of unicode characters? And by characters here we probably me
by twic 3y ago
Is there ever a genuine, non-arbitrary business requirement to limit any string to a certain number of unicode characters? And by characters here we probably mean extended grapheme clusters.
If the data is going to get printed in a monospace font, on a passport or credit card or something, then i can understand a limit on the number of characters. But then it's not full unicode either - you want to constrain the length in some specific character set.
Otherwise, i think limits are always arbitrary. I suspect there is a strong cultural holdover from the days of punched cards here.
- bruce511 3y ago>> If the data is going to get printed in a monospace font, on a passport or credit card In the case of limited space, you absolutely can count characters and limit them in the UI. For data storage though you would provision "enough bytes". Think approximately 4 bytes per character, plus a bit extra just in case. But I agree in most cases the length limits are completely arbitrary and simply made up by the programmer at the time the database is designed. (Hint: They are _always_ too short, especially if the programmer lacks experience.)
- Dylan16807 3y ago> Think approximately 4 bytes per character, plus a bit extra just in case. I hope you don't have too much korean or compound emojis or some other things in that data, then. One of the unicode annexes needed to set a (partial) limit on code points in a single grapheme and the number it picked was 31.