4 ms·
Its greatest weakness is 10 different string encodings. I've always wondered what sort of bugs you could expose with a cert using videotex for the CN fields.
by kevin_thibedeau 5y ago
Its greatest weakness is 10 different string encodings. I've always wondered what sort of bugs you could expose with a cert using videotex for the CN fields.
- jhoechtl 5y agoLike Rust?
- pdimitar 5y agoAs a Rust dev it's news to me that the language has 10 different strings. Care to elaborate?
- codeflo 5y agoNot the OP, but off the top of my head, we have: * str and String, which are the ones we just call “strings” * CStr and CString, for interop with libraries that work with null-terminated strings * OsStr and OsString, for interop with system libraries that expect non-UTF-8 encodings * Path and PathBuf, which are also just strings * [u8] and Vec<u8>, which are encoding-neutral binary strings (&[u8] is the type of b"Hello world") and are useful for interop with e.g. C++’s std::string That’s 10. (For non-Rust people who are curious: In these pairs, the first one is the type of a view of a string that’s stored elsewhere, and the second is the type that actually owns the string data. All of these 10 have their uses, but outside of interfacing with non-Rust libraries, you mostly work with str/String and Path/PathBuf.)
- pdimitar 5y agoOK, technically correct but I still disagree they are actually 10 because aside from `str` (which should be used only for constants really) and `String` everything else is strictly optional and you're not mandated to work with it unless you got a specific scenario (like CStr / CString). Compare this to Haskell where you have lazy and non-lazy / Unicode and non-Unicode strings which is at least 4 (I think there was more but I forgot now) and you are practically forced into using any of them depending on which library you're interacting with -- and I don't mean with C libraries in this instance. I personally never even used anything beyond `str` and `String` for any app development, including a bit lower level stuff (though not embedded or tight integration with system libraries).
- samus 5y agoHaskell also has `String`, which is a linked lazy list of boxed UTF32 characters. Yes, it's as horrible for performance as it sounds. Also, there are `ByteString`s which wrap strings in other encodings.
- codeflo 5y agoI don’t think we actually disagree, see my last paragraph.
- pdimitar 5y agoTrue, I overreacted a little, sorry. Thanks for being a good sport.
- p_l 5y agoWell, you can constrain what kind of string encodings are acceptable in your structs. The reason it has so many is because so many were actually in use, sometimes with important semantic differences that. You can't just hope that stream of 8bit bytes will not have anything outside of accepted in target system string understanding.