2 ms·
Treating strings as arrays of bytes is very reasonable. It is the assumption that each byte is exactly one character that causes trouble.
by bjourne 6y ago
Treating strings as arrays of bytes is very reasonable. It is the assumption that each byte is exactly one character that causes trouble.
- astrange 6y agoYou should treat them as strings, the backing data store is an implementation detail. What do you want to do with individual bytes if you access them? Whatever you do is likely to be incorrect in some language, even English with emoji mixed in or Zalgo text. This also lets you implement compressed small strings (eg in tagged pointers) which is a good memory optimization.