当我使用带有重音字母的 std::isupper() 时我应该怎么做

What should i do when i use std::isupper() with accentuated letter

我必须检查字符串的第一个字符是小写还是大写。

当我使用像 David 这样的英文名字时效果很好,但是当出现带有重音字母的名字,如 Á、É、Í、Ó 等....(如 Árpád)时,它认为它是小写的。

string name;
std::cin>>name;

if(std::isupper(name[0]))
{
std::cout<<"Upper case"<<std::endl;
}
else
{
std::cout<<"Lower case"<<std::endl;
}

默认std::isupper()/std::islower() you are using work with ASCII letters only (ABCDEFGHIJKLMNOPQRSTUVWXYZ and abcdefghijklmnopqrstuvwxyz). To work with other charsets, you need to call std::setlocale() first, or use the std::locale version of std::isupper()/std::islower()的版本,切换到支持您感兴趣的字符的字符集。