Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why std::string doesn't have methods for upper/lower case, format etc? [closed]

Why std::string is not smart at all. Why it doesn't have string manipulation features like Format/sprintf, convert to upper, convert to lower, take input from integer/real, to convert to integer/real, and other important functions any string class should have (Reference: CString, wxString, System.String, BASIC strings...).

I am aware that there are new functions like std::to_string, but.. why string itself is so dumb. Why it is just vector<char>? Why still in stone age? Why standards don't make it smart!?

like image 897
Ajay Avatar asked Jan 28 '26 16:01

Ajay


1 Answers

Case comparisons and conversions, in full generality, are hard and require too much information; it's as simple as that.

In American and British English it's simple indeed.

But what about German? E.g. the lower case ß (which in lower case is one character, but in upper case would be two characters: SS).

What about wide character sets which std::string can support? What about accented characters from other European languages like ë?

There's nothing idiotic about this class at all. It has a well defined specification and the standards committee will not emit functionality that could break the language.

As for formatting, this is largely deferred to the streaming libraries, e.g. std::stringstream. There's no reason to incorporate directly into std::string.

like image 69
Bathsheba Avatar answered Jan 31 '26 07:01

Bathsheba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!