|
|
|
|
|
by wpollock
411 days ago
|
|
Best advice I've heard is to never use the character type in your programming language. Instead, store characters in strings. An array of strings can be used as a string of characters. In this approach, characters become opaque blobs of bytes. This makes it easy to get the two numbers you care about: length in characters and size in bytes. There is some overhead for this, so maybe a technique more suited to backends. Normalization, sanitation and validation steps are best performed in the frontend. Also worth knowing is the ICU library, which is often the easiest way to work with Unicode consistently regardless of programming language. Finally, punycode is a standard way to represent arbitrary Unicode strings as ASCII. It's reversible too (and built into every web browser). You can do size limits on the punycode representation. BTW, you shouldn't store passwords in strings in the first place. Many programming languages have an alternative to hold secrets in memory safely. |
|
I'm really hoping we have very different definitions of "frontend"