我编写了这段代码来删除字符串中字符的重音并将其变为大写:
#include <iostream>
#include <string>
using namespace std;
std::wstring input;
int main()
{
input.reserve(255);
cout << "Enter string to be converted:" <<endl;
getline(std::wcin,input);
for (unsigned int iii=0;iii<input.length();iii++)
{
if(input[iii]== L'ő') input[iii]=L'o';
if(input[iii]== L'ö') input[iii]=L'o';
if(input[iii]== L'ó') input[iii]=L'o';
if(input[iii]== L'ü') input[iii]=L'u';
if(input[iii]== L'ú') input[iii]=L'u';
if(input[iii]== L'ű') input[iii]=L'u';
if(input[iii]== L'é') input[iii]=L'e';
if(input[iii]== L'á') input[iii]=L'a';
if(input[iii]== L'í') input[iii]=L'i';
input[iii]=towupper(input[iii]);
}
std::wcout<<input;
return 0;
}
它使普通字符大写,但忽略带重音的字符并将它们以带重音的小写形式打印。提前致谢!