News for hackers. Stuff that matters.
Re:What can’t the internet handle in 2022? Apostrophes by Cu3PO42 on Tuesday October 04, 2022 @04:11AM (#33077688)
To a degree, Rust does this. The standard string type is always guaranteed to be valid UTF-8. Then there's a string type for the OS native format and a string type for what constitutes a valid path on the file system. Of course, arrays of bytes also exist and so does a type for a null-terminated "CString". Converting between them requires runtime checks (unless you invoke unsafe code and promise you know better than the compiler).

It's cumbersome at times, but a perfectly reasonable tradeoff in my opinion. Some libraries add other string types when they're needed to interact with a system. For example, the windows crate has wide strings.

There are no comments on this comment yet.