There is a code that translates upper case to lower case.

#include <algorithm> #include <iostream> #include <string> #include <ctype.h> int main() { std::string text; std::cout << "Type text(QWERTY): "; std:: getline(std::cin, text); std::cout<<text << " - " ; std::transform(text.begin(), text.end(), text.begin(), tolower); std::cout << text; return 0; 

}

But, if Cyrillic is entered, then Cyrillic is not replaced by lower case. How to make a check whether there is a Cyrillic alphabet or which replacement method to use, so that it would not be necessary to use char and char arrays. Work only with string

  • Set the locale. - αλεχολυτ
  • @alexolut Installed - did not work - umd
  • You now have two questions in one. Decide more specifically what you want - to find the Cyrillic alphabet or correctly convert the register? - andreymal
  • std::wstring will help you - NewView
  • @ MaximDonets can be wrong, and there is no time to write code, but each character in Unicode has a specific number. In essence, the task must be reduced to checking that the given symbol is from the corresponding range of values. - Andrew Kachalin

1 answer 1

Use wstring , wcout , towlower .

 std::setlocale(LC_CTYPE, "ru-RU"); std::wstring text = L"ABC АБВ"; std::wcout << text << " - "; std::transform(text.begin(), text.end(), text.begin(), towlower); std::wcout << text << std::endl; 

Displays abc абв .

  • Did as you advised - does not display anything at all. And if you just copy your example, then instead of Cyrillic it displays question marks - umd