Topic: How to lowercase a std::string


Author: "Tony" <Tony@dontEmail.com>
Date: 1998/12/10
Raw View
What is the method for lowercasing a std:string? Lippman's C++ Primer (1998)
says a method is available if you #include <locale>, but he says he didn't
have an implementation at the time of writing, so he went ahead and used C's
tolower().

I'm wondering how he would have done it if he *had* had a full
implementation. Is there a nice, simple method available? Something along
the lines of:

string lowerStr = myUpperStr.tolower();

seems like an obvious approach, but nothing that seems obvious to me ever
seems available in Standard C++. My beginner's intuition is clearly out of
sync with that of the designers. I see no such method in the string class.

I'm also aware that lowercasing is locale dependent. Again, it seems that
the obvious solution would be:

string lowerStr = myUpperStr.tolower(locale lc = [some default locale]);

Again, I'm apparently out of luck, so how is .tolower() used when you want
to take locale into account?

TIA,
Tony




[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]