You need to apply it in different ways:
for(unsigned i=0;i<str.size();i++) str[i]=std::toupper(str[i],loc);
Or set the global locale
std::locale::global(std::locale("Germany_german"));
and then
std::transform( str.begin(), str.end(), str.begin(), std::toupper );
See: http://www.cplusplus.com/reference/std/locale/tolower/
Note 1 C toupper is different from std :: toupper, which receives std :: locale as a parameter, which uses char only as a parameter, and std::toupper works on both char and wchar_t .
Note 2 std::locale completely broken for the German language, since it works on the basis of characters and cannot convert "ß" to "SS", but it will work for most other characters ...
Note 3: If you need the correct code conversion, including handling characters like "ß", you need a good localization library such as ICU, or Boost.Locale
source share