3 ms·
> but I'm more and more coming to the conclusion that strings are evil and should be treated as opaque byte arrays, whose only available operation is rendering
by merb 7y ago
> but I'm more and more coming to the conclusion that strings are evil and should be treated as opaque byte arrays, whose only available operation is rendering into a bounded area
nope. they are not byte arrays. if treating them as such, you run into many nasty bugs.
today I encountered one (C#):
if (string.Length > 60)
string.Remove(60)
this has a fucking serious bug, especially if you try to show the string afterwards or worse save it inside a database.
strings are arrays of codepoints. NEVER TREAT THEM AS BYTE/CHAR ARRAYS.
- BoppreH 7y agoI meant "byte array" as in "this is a bunch of binary data you should not look into". Like people already do with images. You wouldn't remove a byte from the middle of a JPEG file, and you shouldn't do it with strings either.