How to use tolower function for characters other than ascii

I am trying to apply a lower function to non-ASCII characters. The following code does not work on Linux (Ubuntu), but works on windows.

int main() {
        std:string data="ŽŠ";
        std::transform(data.begin(), data.end(), data.begin(), ::tolower);
        cout<< data << endl;
        return 0;
}

I tried to install language packs but did not work. Can someone tell me what I am missing in this code?

+4
source share
1 answer

::tolower()used in the current locale set in the C library. By "C"default, the locale is only guaranteed to process ASCII characters. Microsoft probably uses a different default standard that matches the current language of the user. This explains why the code may work on Windows.

::setlocale(), ::tolower(). Unicode, ​​ ICU.

+5

All Articles