如何将字符串(wstring)从小写字符转换为大写字符,反之亦然?我在网上搜索,发现有一个STL函数std :: transform.
但到目前为止,我还没想出如何将正确的语言环境对象(例如"Germany_german")赋予该函数.谁能帮帮忙?我的代码看起来像:
wstring strin = L"ABCÄÖÜabcäöü";
wstring str = strin;
locale loc( "Germany_german" ); // ??? how to apply this ???
std::transform( str.begin(), str.end(), str.begin(), (int(*)(int)tolower );
//result: "abcäöüabcäöü"
Run Code Online (Sandbox Code Playgroud)
角色ÄÖÜ和äöü(就像Ae,Oe,Ue)将无法正确转换.
PS:我不喜欢大开关汗,而且我也知道BOOST能胜任一切,我更喜欢STL解决方案.
提前谢谢
哎呀
c++ ×1