4 ms·
Perfect is the enemy of good. Or do you think the current mess is better?
by jhasse 8mo ago
Perfect is the enemy of good. Or do you think the current mess is better?
- jstimpfle 8mo agostd::string _cannot_ be made "always UTF-8". Is that really so contentious? You can still use it to contain UTF-8 data. It is commonly done.
- jhasse 8mo agoI never said always. Just add some new methods for which it has to be UTF-8. All current functions that need an encoding (e.g. text IO) also switch to UTF-8. Of course you could still save arbitrary binary data in it.
- jstimpfle 8mo ago> That's where the standard should come in and say something like "starting with C++26 char is always 1 byte and signed. std::string is always UTF-8" Done, fixed unicode in C++. > I never said always Yes you totally did. And regarding "add some new methods for which it has to be UTF-8", there is no need at all to add UTF-8 methods to std::string. It would be a bad idea. UTF-8 is not bound to a particular type (or C++ type). It works on _any_ byte sequence.
- jhasse 8mo agoYou're right, sorry. Good point, so maybe the standard should just add some functions that take std::string_view. Definitely not add a whole new class like std::u8string ...