3 ms·
The problem is that your method works well if the string is either: - Only meant to be used in a machine-to-machine interface (like a JSON key for instance).
by simias 7y ago
The problem is that your method works well if the string is either:
- Only meant to be used in a machine-to-machine interface (like a JSON key for instance).
- Only meant to be used in a machine-to-human interface (like the text letting you know that you used a wrong password).
For strings that have a special significance to both humans and machines you can still run into problems, mainly because of the many unicode strings that look similar (or sometimes even identical) visually but are encoded with a different byte sequence. Take usernames or URLs for instance.
But in the end Unicode is messy because human languages are messy. As programmers we like well-bounded problems with elegant generic solutions. This clearly isn't possible here and we have to deal with it.