Use the locale-aware version of tolower
, but don't forget to also set the C locale.
For example:
#include <clocale>
#include <locale>
#include <iostream>
int main()
{
std::setlocale(LC_CTYPE, "");
std::wcout << L"The letter is: " << L'Я' << L" => "
<< std::tolower(L'Я', std::locale("")) << std::endl;
}
This prints:
The letter is: Я => я
Using locales in iostreams is tricky business, and there's a whole Pandora's box hidden behind this. For example, you can imbue streams with a locale, and you can manage multiple locales at once, and in particular you can have one per thread (which may be necessary for stateful string encoding conversions)... someone should write a book about that (or instead use Boost.Locale).