3 ms·
> with the first byte containing the length of the actual string And the wheels fall off with the first string longer than 255 characters.
by WalterBright 4y ago
> with the first byte containing the length of the actual string
And the wheels fall off with the first string longer than 255 characters.
- initplus 4y agoYou can fix this issue by using a variable width integer encoding for the size.
- burntsushi 4y agoIt might fix that particular issue, but you still have the same problem that NUL terminated strings have: it's not possible to cheaply create views/slices of a string using the same type.
- mikewarot 4y agoWhich is why Free Pascal strings are so awesome. I've personally stuffed a billion bytes on one, without issues. They are automatic reference counted, and as close to magic as you can get. You can return one from a function without issue. However, Free Pascal has the worst documentation of any major project I've ever encountered (The exact opposite of Turbo Pascal), so I can't link to a good reference. Their Wiki is a black hole of nuance and sucks all useful stuff off the internet.