So I am trying to use std::tolower with custom locale.
It works with wstring, but with u32string I receive:
what(): std::bad_cast
This is what I do
auto loc = std::locale("el_GR.UTF-8");
wstring wtest{L"πρόβλημα"};
u32string utest{U"πρόβλημα"};
auto toLower = [&](auto c) { return std::toupper(c, loc); };
std::transform(wtest.begin(), wtest.end(), wtest.begin(), toLower); //ok
std::transform(utest.begin(), utest.end(), utest.begin(), toLower); //bad_cast
Locales are required to support
std::ctypefacets only forcharandwchar_t, i.e.std::stringandstd::wstring. Any further specializations are optional.It seems that the implementation you are using does not provide such a specialization for
char32_t, i.e.std::u32string.