9
我的程序檢查德語中的大寫字母。打印所有std ::語言環境名稱(Windows)
#include <iostream>
#include <boost/algorithm/string/classification.hpp>
#include <boost/locale.hpp>
using namespace std;
int main()
{
locale::global(locale("Germany_german"));
//locale::global(locale("de_DE.UTF-8")); //Also tried "de_DE.UTF-8", but does not work
string str1 = "über";
cout << boolalpha << any_of(str1.begin(), str1.end(), boost::algorithm::is_upper()) << endl;
string str2 = "Ää";
cout << boolalpha << any_of(str2.begin(), str2.end(), boost::algorithm::is_upper()) << endl;
return 0;
}
程序錯誤崩潰的控制檯
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
我不知道確切的語言環境字符串是什麼,「de_DE.UTF-8」不正常工作。
有什麼辦法,我可以得到精確的區域名稱字符串由操作系統支持的所有語言環境。可能在頭文件中有一個列表,但我沒有看到任何東西<locale>
頭。
您可以在命令行上執行'locale -a'。 – 0x499602D2
我在Windows上 – user1
「de-DE」和「German_Germany」應該可以工作。至少,你應該能夠從這些字符串構造'locale'。 –